On Jun 19, 2017, at 12:29 PM, Thomas Kellerer wrote:
>
> Israel Brewster schrieb am 19.06.2017 um 22:17:
>> SELECT
>> ...
>> (SELECT
>> array_agg(to_json(row(notedate,username,note)))
>> FROM sabrenotes
>> INNER JOIN users ON author=users.id
>> WHERE ticket=sabretickets.id ) notes
>> FROM tickets
On Mon, Jun 19, 2017 at 1:32 PM, David G. Johnston
wrote:
> On Mon, Jun 19, 2017 at 1:29 PM, Thomas Kellerer wrote:
>>
>> Israel Brewster schrieb am 19.06.2017 um 22:17:
>>>
>>> SELECT
>>> ...
>>> (SELECT
>>> array_agg(to_json(row(notedate,username,note)))
>>> FROM sabrenotes
>>> INNER JOIN users
Israel Brewster schrieb am 19.06.2017 um 22:17:
SELECT
...
(SELECT
array_agg(to_json(row(notedate,username,note)))
FROM sabrenotes
INNER JOIN users ON author=users.id
WHERE ticket=sabretickets.id ) notes
FROM tickets
WHERE ...
The only problem with this query is that the notes aren't sorted. Of
you were close, try the following (untesting). You need the alias on the outer
my_table for this to work
select year report_year,
sum(amount),
sum(select amount from my_table where year <= a.year)
from my_table a
group by report_year;
-- Original Message --
You both are SO right! I sent that off and tried a couple of
things and realized I was close but not close enough. I really
appreciate the kind responses. Sometimes it's so hard to ask a
question without feeling so foolish and then feeling worse when the
answers are sarcastic. Thank you!
Good
Phong & Ronni Bounmixay <[EMAIL PROTECTED]> writes:
> I want to do in postgresql what I do in oracle:
> select year report_year,
> sum(amount),
> sum(select amount from my_table where year <= report_year)
> from my_table
> group by report_year;
That doesn't really work in Oracle
On Thu, 30 Aug 2001, Ben-Nes Michael wrote:
> Can I:
>
> select *, sum_rows as ( select count(*) from table2; ) from table1;
I think you need to say:
select *, (select count(*) from table2) as sum_rows from table1;
But this won't be a very interesting query because the sum_rows column
will be