Re: subquery/alias question
От | Alvaro Herrera |
---|---|
Тема | Re: subquery/alias question |
Дата | |
Msg-id | 20070926125538.GF5584@alvh.no-ip.org обсуждение исходный текст |
Ответ на | Re: subquery/alias question (Madison Kelly <linux@alteeve.com>) |
Ответы |
Solved! Was: (subquery/alias question)
|
Список | pgsql-general |
Madison Kelly wrote: > Thanks for your reply! > > Unfortunately, in both cases I get the error: > > nmc=> SELECT dom_id, dom_name, COUNT(usr_dom_id) AS usr_count FROM domains > JOIN users ON (usr_dom_id=dom_id) HAVING COUNT (usr_dom_id) > 0 ORDER BY > dom_name; > ERROR: syntax error at or near "COUNT" at character 25 > LINE 1: SELECT dom_id, dom_name COUNT(usr_dom_id) AS usr_count FROM ... Try to avoid missing the comma before the COUNT (and do not cheat when cut'n pasting ...) Also it seems you will need a GROUP BY clause: GROUP BY dom_id, dom_name (placed just before the HAVING clause). -- Alvaro Herrera http://www.amazon.com/gp/registry/CTMLCN8V17R4 "Some men are heterosexual, and some are bisexual, and some men don't think about sex at all... they become lawyers" (Woody Allen)
В списке pgsql-general по дате отправления: