SQL STUFF Sipariş Bazında Fatura Numara Virgülle ayırma
<blockquote> <p>SELECT<br /> STL.ORDFICHEREF,<br /> FaturaNo=STUFF((SELECT<br /> ','+INV.FICHENO <br /> FROM LG_001_01_STLINE STLSTUF <br /> LEFT JOIN LG_001_01_STFICHE STF ON STF.LOGICALREF=STLSTUF.STFICHEREF<br /> LEFT JOIN LG_001_01_INVOICE INV ON INV.LOGICALREF=STF.INVOICEREF<br /> WHERE ORDFICHEREF>0<br /> AND STLSTUF.ORDFICHEREF=STL.ORDFICHEREF<br /> GROUP BY STLSTUF.ORDFICHEREF,INV.FICHENO</p> <p> FOR XML PATH('')),1,1,'')<br /> FROM LG_001_01_STLINE STL <br /> LEFT JOIN LG_001_01_STFICHE STF ON STF.LOGICALREF=STL.STFICHEREF<br /> LEFT JOIN LG_001_01_INVOICE INV ON INV.LOGICALREF=STF.INVOICEREF<br /> WHERE ORDFICHEREF>0<br /> GROUP BY ORDFICHEREF</p> </blockquote>