Cita:
Iniciado por jerrymix no entendi donde debere poner el where
Madre mia que pregunta :S
Código SQL:
Ver originalSELECT CASE WHEN Datepart(MONTH, T0.DocDate) = 1
THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-01 ' WHEN Datepart(MONTH, T0.DocDate)= 2
THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-02 ' WHEN Datepart(MONTH, T0.DocDate)= 3
THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-03 ' WHEN Datepart(MONTH, T0.DocDate)= 4
THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-04 ' WHEN Datepart(MONTH, T0.DocDate)= 5
THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-05 ' WHEN Datepart(MONTH, T0.DocDate)= 6
THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-06 ' WHEN Datepart(MONTH, T0.DocDate)= 7
THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-07 ' WHEN Datepart(MONTH, T0.DocDate)= 8
THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-08 ' WHEN Datepart(MONTH, T0.DocDate)= 9
THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-09 ' WHEN Datepart(MONTH, T0.DocDate)= 10
THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-10 ' WHEN Datepart(MONTH, T0.DocDate)= 11
THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-11 ' WHEN Datepart(MONTH, T0.DocDate)= 12
THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-12 ' ELSE 'bones' END AS 'Periodo' WHERE YEAR(tucolumna) >= 2012 AND datepart(mm,tucolumna) >=4
En el query viene lo del mes tambien :)