replace similar rows with a 'parametric' one
From: Ammammata <ammammata_at_tiscalinet.it>
Date: Tue, 4 Jun 2019 07:25:38 +0000 (UTC)
Message-ID: <XnsAA645FE7417Dammammatatiscalineti_at_148.251.67.112>
this is part of a query that sums quantities per month, a sort of pivot:
Date: Tue, 4 Jun 2019 07:25:38 +0000 (UTC)
Message-ID: <XnsAA645FE7417Dammammatatiscalineti_at_148.251.67.112>
this is part of a query that sums quantities per month, a sort of pivot:
, isnull(sum(case when PCN = 'P1' and DelivMonth='01' then QtyDelivered
end), 0) as P01 -- Jan
, isnull(sum(case when PCN = 'P1' and DelivMonth='02' then QtyDelivered
end), 0) as P02 -- Feb
, isnull(sum(case when PCN = 'P1' and DelivMonth='03' then QtyDelivered
end), 0) as P03 -- Mar
, isnull(sum(case when PCN = 'P1' and DelivMonth='04' then QtyDelivered
end), 0) as P04 -- Apr
and so on, until 12 (December)
can I replace with something like:
, isnull(sum(case when PCN = 'P1' then QtyDelivered end), 0) as
P$DelivMonth$ -- DelivMonth is the month
using the value of DelivMonth as part of the field name?
note: I used the $ sign as delimiter, but it's just an example, maybe I must use something else... !£^¬¦#& etc
-- /-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\ -=- -=- -=- -=- -=- -=- -=- -=- - -=- >>>>> http://www.bb2002.it :) <<<<< ........... [ al lavoro ] ...........Received on Tue Jun 04 2019 - 09:25:38 CEST