From: Richard Huxton <dev@archonet.com>
To: RPK <rpk.general@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: SQL query to display like this
Date: Fri, 24 Aug 2007 12:36:05 +0100
Message-ID: <46CEC2A5.9090706@archonet.com> (raw)
In-Reply-To: <12310093.post@talk.nabble.com>
References: <12310093.post@talk.nabble.com>
RPK wrote:
> select PaySlipDate,EmpID,
> case ADCode when 'GPF' then ADAmount else 0 end GPF,
> case ADCode when 'GPF.ADV' then ADAmount else 0 end 'GPF.ADV'
> from EmpSalaryRecord
>
> It is showing like this:
>
> Date EmpID GPF GPF.ADV
> -----------------------------------------
> 01-Jul-07 101 0 0
> 01-Jul-07 101 150 0
> 01-Jul-07 102 0 100
> 01-Jul-07 103 0 0
> 01-Jul-07 103 1000 0
> 01-Jul-07 103 0 1000
>
> It is showing multiple records of each employee for each date.
No it's not. It's showing 2 records for empid=101, 3 for empid=103 but
only 1 for empid=102. That says to me you have multiple rows in your
table for each (date,empid) combination.
If you want to eliminate them, either filter on AdCode or perhaps SUM()
your GPF/GPF.ADV colums.
--
Richard Huxton
Archonet Ltd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, rpk.general@gmail.com
Subject: Re: SQL query to display like this
In-Reply-To: <46CEC2A5.9090706@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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