Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Need to include duplicate records in sub query

$
0
0

Hi All,

         I am using the following query and i am getting error message that your sub query return dupliate records and throwing error. Actually i need these duplicate records for my report. I want to get records for whole year like

   JAN FEB MARCH ..   ...    ...

and idea how i can achieve this task and 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'))


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>