Posted - 04/04/2012 : 05:39:29
| Hi All,
I am trying to write a sql query using sql server 2000. My query and the result set looks like below
select h.UPRN, h.address1 as fulladdress, h.jobid, h.engineername, l.make as boilermake, l.model as boilermodel,
l.locationcode, l.apptype, h.tightness, h.emergency as emergencycontrols, l.serialno, l.cp12labwarn
from tblcp12_lines l join tblcp12_headers h on h.jobid = l.jobid
where h.jobid = '700936' and isnull(CP12Status,'') <> 'Removed' and isnull(CP12Details,'') <> 'NO GAS FOUND IN PROPERTY.'
UPRN fulladdress jobid EngineerName Boilermake BoilerModel locationcode apptype tightness emergencycontrols serialno cp12labwarn
6224156 52, Ridgeview Close 700936 Jonathan Afshin NEW WORLD UNK KITCHEN COOKER Pass Yes UNKNOWN NULL
6224156 52, Ridgeview Close 700936 Jonathan Afshin POTTERTON PROFILE 50E COMPARTMENT BOILER Pass Yes UNKNOWN No
6224156 52, Ridgeview Close 700936 Jonathan Afshin UNKNOWN UNK FRONT ROOM GAS FIRE Pass Yes UNKNOWN No
6224156 52, Ridgeview Close 700936 Jonathan Afshin CARBON MONOXIDE DETETOR FIREANGEL BEDROOM Carbon Monoxide dete Pass Yes UNKNOWN NULL
6224156 52, Ridgeview Close 700936 Jonathan Afshin UNKNOWN UNK HALL Smoke detector Pass Yes UNKNOWN NULL
I want to change it to return in a single row which should have all the details similar to the line in apptype as Boilder and along with that i need to get other appliance types like below
6224156 , 52,Ridgeview Close, 700936, Jonathan Afshin, Potterton, Profile 50E, Compartment, Boiler, Cooker, Gas Fire, Carbon Monoxide dete, Pass , Yes, No (This is cp12labwarn which should be No if any one of the rows contains No otherwise Null)
Please do let me know if you need more details to get this results.
I am using SQL Server 2000.
Thanks in advance
Edited by - swapna.anu on 04/04/2012 05:42:03