on 06-19-2009 4:53 PM
Colegas:
Tengo este query:
SELECT T0.DocEntry, T0.DueDate, (T0.InsTotal -T0.PaidToDate) as 'Febrero 09' FROM INV6 T0 INNER JOIN OINV T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T1.CardCode = T2.CardCode WHERE T0.Status = 'o' and month(T0.DueDate) = '02' and T2.GroupCode = '100' and year(T0.Duedate) = '2009' ORDER BY T0.DueDate
Al darle ejecutar me trae las columnas correspondientes y una de ellas es la de 'Febrero 09', ahora quisiera agregarle otra columna con los demás meses: 'Marzo 09', Abril '09', etc que me traiga la misma información de acuerdo al mes y año de vencimiento. Alguna idea?????
Saludos
podria ser algo asi:
SELECT T0.DocEntry, T0.DueDate,' Febrero 09'= case when month(t0.duedate)='02' then
(T0.InsTotal -T0.PaidToDate) end,
'Marzo 09' = case when month(t0.duedate)='03' then (T0.InsTotal -T0.PaidToDate)
end FROM INV6 T0 INNER JOIN OINV T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2
ON T1.CardCode = T2.CardCode WHERE T0.Status = 'o' and T2.GroupCode = '100' and year(T0.Duedate) = '2009' ORDER BY T0.DueDate
A ver si te sirve, usa el case, y te va a ayudar. ya solo depuras el where de donde a donde quieres que te muestra las columnas oks??..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
y cómo sería en semanas????
Saludos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
12 | |
10 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.