Re: create aggregate function 'count_bool( column_name, boolean )'
| От | Richard Broersma Jr |
|---|---|
| Тема | Re: create aggregate function 'count_bool( column_name, boolean )' |
| Дата | |
| Msg-id | 20060707155924.93209.qmail@web31806.mail.mud.yahoo.com обсуждение исходный текст |
| Ответ на | create aggregate function 'count_bool( column_name, boolean )' ("James Moliere" <jmoliere@ucsd.edu>) |
| Список | pgsql-sql |
> so now I can create the statement > select distict product_id, count_bool(purchased, true), > count_bool(was_selected, true) from some_table group by product_id; > > instead of breaking the query into 3 seperate queries > > select distict product_id from some_table; > select count(purchased) from product_id where purchased = true; > select count(was_selected) from some_table where was_selected = true; > Am I missing a detail with SQL based aggregate function development? > Any help would be appreciated. how about: select product_id, ( select count(purchased) from some_table as A2 where purchased=true and A1.product_id=A2.product_id ) as TP, ( select count(selected) from some_table as A3 where purchased=true andA1.product_id=A3.product_id ) as TS from some_table as A1 group by product_id; Regards, Richard Broersma Jr.
В списке pgsql-sql по дате отправления: