select
CONVERT(VARCHAR(2), B.BILLDATE,101 ) BILLDATE,
B.BILLAMT , b.sourceord , taro.client_id
from [billing] as b with (nolock)
inner join [orders] as srco with (nolock) on (b.sourceord = srco.order_id)
inner join [funders] as fs on (srco.funder_id = fs.funder_id)
inner join [orders] as taro with (nolock) on (b.targetord = taro.order_id)
inner join [funders] as ft on (taro.funder_id = ft.funder_id)
inner join [clients] as c with (nolock) on (c.client_id = b.client_id)
WHERE FS.CODE <> FT.CODE
AND b.billdate >= @dt_StartDate AND b.billdate < @dt_EndDate_RPT
) DATATABLE
PIVOT
(
SUM(BILLAMT)
FOR BILLDATE
IN ([01],[02],[03],[04], [05], [06],[07],[08],[09],[10],[11],[12])
) PIVOTTABLE
Hi
I need a help about PIVOTTABLE. It is a quarter wise report but the quater is not fixed. User can select any 3 months. I don't want to use
([01],[02],[03],[04], [05], [06],[07],[08],[09],[10],[11],[12])
I want to use (Month1, Month2, Month3) means user select any 3 months but the result comes in (Month1, Month2, Month3)
My english is not good sorry about
Thanks
CONVERT(VARCHAR(2), B.BILLDATE,101 ) BILLDATE,
B.BILLAMT , b.sourceord , taro.client_id
from [billing] as b with (nolock)
inner join [orders] as srco with (nolock) on (b.sourceord = srco.order_id)
inner join [funders] as fs on (srco.funder_id = fs.funder_id)
inner join [orders] as taro with (nolock) on (b.targetord = taro.order_id)
inner join [funders] as ft on (taro.funder_id = ft.funder_id)
inner join [clients] as c with (nolock) on (c.client_id = b.client_id)
WHERE FS.CODE <> FT.CODE
AND b.billdate >= @dt_StartDate AND b.billdate < @dt_EndDate_RPT
) DATATABLE
PIVOT
(
SUM(BILLAMT)
FOR BILLDATE
IN ([01],[02],[03],[04], [05], [06],[07],[08],[09],[10],[11],[12])
) PIVOTTABLE
Hi
I need a help about PIVOTTABLE. It is a quarter wise report but the quater is not fixed. User can select any 3 months. I don't want to use
([01],[02],[03],[04], [05], [06],[07],[08],[09],[10],[11],[12])
I want to use (Month1, Month2, Month3) means user select any 3 months but the result comes in (Month1, Month2, Month3)
My english is not good sorry about
Thanks