Tag Info

New answers tagged

1

If I figured out correctly what you're doing, you could also do it using unpivot, something like this with the separate columns in 2 CTEs and join them side by side using number for row_number: ;with D1 as ( select row_number() over (order by (select null)) as RN, p8_14 from ( select prodt_8, prodt_9, prodt_10 from test ) p unpivot ( p8_14 for ...


0

This solved my problem. It doesnt hurt to think a little Select Top 3 [Coluna],[Valor] From( Select Round(Case When Round(Avg(Convert(float,HC08)),1) = 0 Then 0 Else Round(Avg(Convert(float,Prod08)),1) / Round(Avg(Convert(float,HC08)),1) End,1) As Prodt_8, Round(Case When Round(Avg(Convert(float,HC09)),1) = 0 Then 0 ...


0

Your best bet is probably to use dynamic SQL to pivot your data. Here try this out. IF OBJECT_ID('tempdb..#tblItems') IS NOT NULL DROP TABLE #tblItems; IF OBJECT_ID('tempdb..##tblItemsTotal') IS NOT NULL DROP TABLE ##tblItemsTotal; CREATE TABLE #tblItems ( UniqueCode CHAR(4), [Description] VARCHAR(100), [Date] Date, Amount ...



Top 50 recent answers are included