SELECT sid.FieldBoyName, st.batchnumber itembatch,ftm.manufacturename,ftm.machinename, ftm.packsize,st.barcodeno,DATE_FORMAT(st.ExpiryDate,'%d-%b-%Y')ExpiryDate, sm.GSTIN FromGSTN,sm.state fromstate,sm1.state tostate, sm1.GSTIN ToGSTN, sid.batchnumber, sid.IssueInvoiceNo, if(id.IndentType='SI','SALES INDENT','PURCHASE INDENT') IndentType, id.IndentNo,TrimZero(id.ReceiveQty)ReceiveQty,fr.`Location` AS FromLocation,fr.storelocationaddress FromLocationAddress,fr1.`Location` AS ToLocation,fr1.storelocationaddress ToLocationAddress,id.ItemName,TrimZero(sid.sendqty) issueQty,id.MinorUnitName UnitType, TrimZero(st.Rate)Rate,TrimZero(ST.DiscountAmount)DiscountPer,TrimZero(ST.unitprice*sid.sendqty)NetAmount,ST.unitprice*sid.sendqty NetAmount1,st.TaxPer, if(fr.stateid<>fr1.stateid, TrimZero((ST.RATE-ST.DiscountAmount)*(IFNULL((SELECT sum(percentage) FROM st_taxchargedlist WHERE `stockid`=st.stockid LIMIT 1) ,'0')*0.01)),0) TaxPerIGST ,if(fr.stateid=fr1.stateid, TrimZero((ST.RATE-ST.DiscountAmount)*(IFNULL((SELECT sum(percentage)/2 FROM st_taxchargedlist WHERE `stockid`=st.stockid LIMIT 1) ,'0')*0.01)),0) TaxPerCGST ,if(fr.stateid=fr1.stateid, TrimZero((ST.RATE-ST.DiscountAmount)*(IFNULL((SELECT sum(percentage)/2 FROM st_taxchargedlist WHERE `stockid`=st.stockid LIMIT 1) ,'0')*0.01)),0) TaxPerSGST ,fr.GSTNNO FromGSTNNo, fr1.GSTNNO ToGSTNNo, id.Narration,if(reqqty=id.rejectqty,1,0) isApproved,DATE_FORMAT(sid.datetime,'%d/%b/%Y %I:%i %p') dtEntry, (select house_no from employee_master where employee_id=sid.UserID) EmpName ,ftm.HsnCode FROM st_indent_detail id INNER JOIN st_itemmaster ftm ON id.ItemId=ftm.ItemID INNER JOIN st_locationmaster fr ON fr.`locationid`=id.`tolocationid` INNER JOIN f_panel_master fpm ON fpm.`Panel_ID`=fr.`Panel_ID` INNER JOIN centre_master cm on cm.`CentreID`=CASE WHEN fpm.`PanelType` ='Centre' then fpm.`CentreID` else fpm.tagprocessinglabid END AND fpm.`PanelType` in('Centre','PUP') and fpm.IsActive=1 INNER JOIN state_master sm ON sm.`id`=cm.`StateID` INNER JOIN st_locationmaster fr1 ON fr1.`locationid`=id.`Fromlocationid` INNER JOIN f_panel_master fpm1 ON fpm1.`Panel_ID`=fr1.`Panel_ID` INNER JOIN centre_master cm1 on cm1.`CentreID`=CASE WHEN fpm1.`PanelType` ='Centre' then fpm1.`CentreID` else fpm1.tagprocessinglabid END AND fpm1.`PanelType` in('Centre','PUP') and fpm1.IsActive=1 INNER JOIN state_master sm1 ON sm1.`id`=cm1.`StateID` inner join st_indentissuedetail sid on sid.indentno=id.indentno and sid.itemid=id.itemid inner join st_nmstock st on st.stockid=sid.stockid and st.itemid=sid.itemid WHERE sid.IssueInvoiceNo='Direct-Inv-25020021' and id.IsActive=1 group by sid.itemid,st.batchnumber,st.stockid order by id.rate desc,itemname asc