pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedNeed Help : Query problem
2+ messages / 2 participants
[nested] [flat]
* Need Help : Query problem
@ 2003-11-19 01:26 Abdul Wahab Dahalan <wahab@mimos.my>
0 siblings, 1 reply; 2+ messages in thread
From: Abdul Wahab Dahalan @ 2003-11-19 01:26 UTC (permalink / raw)
To: pgsql-sql
Hi Everybody!
If I've a table like below
kk | kj | pngk | vote
----+----+------+------
01 | 01 | a | 10
01 | 01 | b | 10
01 | 01 | c | 10
01 | 02 | a | 10
01 | 02 | b | 10
01 | 03 | a | 10
How do I write a query so that I can get a result as below
[ select only a record/s with same kk and kj but different pngk.
For example here I've 3 records with same kk=01,kj=01 but diff pngk=a,b,c
and 2 records with same kk=01,kj=02 but diff pngk=a,b]
> kk | kj | pngk | vote
> ----+----+------+------
> 01 | 01 | a | 10
> 01 | 01 | b | 10
> 01 | 01 | c | 10
> 01 | 02 | a | 10
> 01 | 02 | b | 10
Thanks.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Need Help : Query problem
@ 2003-11-19 10:34 Michael Glaesemann <grzm@myrealbox.com>
parent: Abdul Wahab Dahalan <wahab@mimos.my>
0 siblings, 0 replies; 2+ messages in thread
From: Michael Glaesemann @ 2003-11-19 10:34 UTC (permalink / raw)
To: Abdul Wahab Dahalan <wahab@mimos.my>; +Cc: pgsql-sql
On Wednesday, November 19, 2003, at 10:26 AM, Abdul Wahab Dahalan wrote:
>
> How do I write a query so that I can get a result as below
> [ select only a record/s with same kk and kj but different pngk.
> For example here I've 3 records with same kk=01,kj=01 but diff
> pngk=a,b,c
> and 2 records with same kk=01,kj=02 but diff pngk=a,b]
I think you'll want to take a look at using GROUP BY
<http://www.postgresql.org/docs/7.4/static/queries-table-
expressions.html#queries-group>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-11-19 10:34 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-11-19 01:26 Need Help : Query problem Abdul Wahab Dahalan <wahab@mimos.my>
2003-11-19 10:34 ` Michael Glaesemann <grzm@myrealbox.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox