Wednesday, Decem2:40:58 PM - David Gillett I can get ne table to act correctly, but the second multiple rows table I cannot get it to sum a column if meets specific criteria. It is a script that has one table that have a single row for an ID and two tables with multiple rows. I need to ask someone about a script that I am working on and I cannot get it to work. LEN(STUFF((SELECT DISTINCT QUOTENAME( COLLNAME)+',' FROM #TEMPCOLLS FOR XML PATH('')), 1, 0, ''))-1) )+')) AS PIVOTTABLE ('+(SELECT LEFT (STUFF((SELECT QUOTENAME(COLLNAME)+',' FROM #TEMPCOLLS FOR XML PATH('')), 1, 0, ''), SELECT DISTINCT COLLNAME AS COLLNAME INTO #TEMPCOLLS FROM #TEMPTABLE JOIN PRODUCTION.PRODUCT PP ON SOD.PRODUCTID =PP.PRODUCTID YEAR(SOD.MODIFIEDDATE)AS ROWSDATA, - ROWS ,РЕДОВЕ In table for pivot you place your data for pivot Here is what i manage to make after long time ot procedure using for this So may have you or any of the other readers some suggestions for me. If I run the pivot without any flexible strukture, I get the customer ID. So the customer ID is included in query before the pivot function, but doesn't appear later. In my case I reduce the values on categories per customer, and for some joins later I need the customer id.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |