mysql - i want to select and display two coluomns ,i.e itemcode and transdate in the subquery -
select itemcode,description,location,stocklevel,wtavg_cost,dddvalue hms_pha_stock c c.stocklevel>0 , itemcode not in ( select itemcode hms_pha_tranheader a, hms_pha_transaction b a.refno = b.refno , a.trantype = b.trantype , a.trantype in ('pto','pis') , b.location ='cph' , a.transdate between '2016-11-01' , '2016-11-08' ) , c.location ='cph' group itemcode
you have used subquery in where clause. there can select 1 column satisfy clause condition.
below have modified query according requirement
select c.itemcode, description, location, stocklevel, wtavg_cost, dddvalue hms_pha_stock c left join (select itemcode, transdate hms_pha_tranheader a, hms_pha_transaction b a.refno = b.refno , a.trantype = b.trantype , a.trantype in ( 'pto', 'pis' ) , b.location = 'cph' , a.transdate between '2016-11-01' , '2016-11-08') ljoin on c.itemcode = ljoin.itemcode c.stocklevel > 0 , ljoin.itemcode null , c.location = 'cph' group c.itemcode
hope should solve problem
Comments
Post a Comment