SQL Query Help Please !

From: GrGsM <shaik2(at)navionicsindia(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: SQL Query Help Please !
Date: 2010-07-06 07:06:06
Message-ID: 29082529.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi all

I am using the following query for data to be displayed in crosstab :

SELECT closedate,status,
SUM (CASE WHEN empcode = 'NT-028' THEN 1 ELSE 0 END) AS NT028,
SUM (CASE WHEN empcode = 'NT-031' THEN 1 ELSE 0 END) AS NT031,
SUM (CASE WHEN empcode = 'NT-050' THEN 1 ELSE 0 END) AS NT050,
SUM (CASE WHEN empcode = 'NT-062' THEN 1 ELSE 0 END) AS NT062
FROM dbcleaning
WHERE status = 'Fixed'
AND empcode IN
('NT-028',
'NT-031',
'NT-050',
'NT-062')
GROUP BY closedate, status

Now i need a column in the same result of the query which shows the
difference between the two columns .

For Example :

the result shoud be

Closedate , status , NT028, NT031, NT050,NT062 , NT028-NT031

Please note the last column in bold, i need the difference .

Any help will be highly appreciated
--
View this message in context: http://old.nabble.com/SQL-Query-Help-Please-%21-tp29082529p29082529.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Schuchardt 2010-07-06 09:17:07 Transform_Null_Equals does not work in Functions
Previous Message Thomas Kellerer 2010-07-06 06:55:47 Re: moderninzing/upgrading mail list format