Query combination query.
От | john-paul delaney |
---|---|
Тема | Query combination query. |
Дата | |
Msg-id | Pine.LNX.4.44.0502221203500.13362-100000@angelico.justatest.com обсуждение исходный текст |
Ответы |
Re: Query combination query.
|
Список | pgsql-novice |
Hello List... Newbie question - is it possible to combine the following two queries into one query statement returning, subject, created, topic_id, count? thanks, /j-p. (Query1) SELECT subject, created, topic_id FROM ap_forum_msg WHERE topic_seq = 1; subject | created | topic_id -----------------+-------------------------------+---------- A topic test 00 | 2005-02-22 09:14:25.444209+01 | 1 A topic test 01 | 2005-02-22 09:15:44.320408+01 | 2 (Query 2) SELECT topic_id, count(topic_seq) FROM ap_forum_msg GROUP BY topic_id; topic_id | count ----------+------- 1 | 2 2 | 3 (Table ap_forum_msg) Column | Type | Modifiers ----------+--------------------------+--------------- topic_id | integer | not null topic_seq | integer | not null author_id | integer | not null created | timestamp with time zone | default now() subject | character varying(100) | msg_text | character varying | forum_id | integer | not null Indexes: ap_forum_msg_pkey primary key btree (topic_id, topic_seq) Foreign Key constraints: $1 FOREIGN KEY (author_id) REFERENCES apo_artist(apo_art_id) ON UPDATE NO ACTION ON DELETE NO ACTION, $2 FOREIGN KEY (forum_id) REFERENCES ap_forum(forum_id) ON UPDATE NO ACTION ON DELETE CASCADE --
В списке pgsql-novice по дате отправления: