Re: Need Help

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Abdul Wahab Dahalan <wahab(at)mimos(dot)my>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Need Help
Date: 2003-11-14 05:11:53
Message-ID: 20031114051153.GB29956@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Nov 14, 2003 at 09:04:47 +0800,
Abdul Wahab Dahalan <wahab(at)mimos(dot)my> wrote:
> Hi!
>
> If I've a table like this
>
> kk kj pngk vote
> 01 02 a 12
> 01 02 b 10
> 01 03 c 5
>
> and I want to have a query so that it give me a result as below.
>
> The condition is for each record with the same kk and kj
> but difference pngk will be give a mark *;
> [In this example for record 1 and record 2 we have same kk=01 and kj=02
> but difference pngk a and b so we give * for the mark]
>
>
> kk kj pngk vote mark
> 01 02 a 12 *
> 01 02 b 10 *
> 01 03 c 5
>
> How should I write the query?

You could do something like:
select a.kk, a.kj, a.pngk, a.vote, b.star
from table a left join
(select '*' star, kk, kj from table group by kk, kj having count(*) > 1) b
on (a.kk = b.kk and a.kj = b.kj);

I didn't test this so there might be a syntax problem, but it should make it
clear how to do what you want.

In response to

  • Need Help at 2003-11-14 01:04:47 from Abdul Wahab Dahalan

Browse pgsql-sql by date

  From Date Subject
Next Message Gulshan Babajee 2003-11-14 05:30:27 Compare strings which resembles each other
Previous Message Abdul Wahab Dahalan 2003-11-14 01:04:47 Need Help