Hi i am running the following query and i am getting message that sub query return duplicate records and that why query is failing. Basically i need duplicate records because i need to show them in report. My query is as follows
select pmnum
,SITEID,
(select description from locations where pm.location = locations.location and pm.siteid=locations.siteid) as site,
(select description from commodities where commodities.commodity= pm.commoditygroup) as workcategory,
description, (select wonum from workorder where workorder.pmnum = pm.pmnum
and targstartdate < '2013-02-01') as jan,
(select wonum from workorder where workorder.pmnum = pm.pmnum and
workorder.status<>'CAN' and targstartdate >= '2013-02-01' and
targstartdate < '2013-03-01') as feb,
(select wonum from workorder where workorder.pmnum = pm.pmnum and
workorder.status<>'CAN' and targstartdate >= '2013-03-01' and
targstartdate < '2013-04-01') as mar
(select name from companies where companies.company = pm.vendor) as contractor
from pm where ((PM.siteid = 'AAA'))
so in simple words i want to create different columns for whole year
JAN FEB MARC -- -- --
Is there any other way i can achieve this task. Thanks
select pmnum
,SITEID,
(select description from locations where pm.location = locations.location and pm.siteid=locations.siteid) as site,
(select description from commodities where commodities.commodity= pm.commoditygroup) as workcategory,
description, (select wonum from workorder where workorder.pmnum = pm.pmnum
and targstartdate < '2013-02-01') as jan,
(select wonum from workorder where workorder.pmnum = pm.pmnum and
workorder.status<>'CAN' and targstartdate >= '2013-02-01' and
targstartdate < '2013-03-01') as feb,
(select wonum from workorder where workorder.pmnum = pm.pmnum and
workorder.status<>'CAN' and targstartdate >= '2013-03-01' and
targstartdate < '2013-04-01') as mar
(select name from companies where companies.company = pm.vendor) as contractor
from pm where ((PM.siteid = 'AAA'))
so in simple words i want to create different columns for whole year
JAN FEB MARC -- -- --
Is there any other way i can achieve this task. Thanks