cfriedberg
MIS
(If you copy the code into an editor without proportional fonts, the columns will line up.)
I have the following table:
BCCODE BDATE BUV BPRICE BQUAN Ext. Price
5069 7/1/2002 0 0.11 62 6.82
5069 7/1/2002 0 1.1 38 41.8
5069 7/6/2002 6.977 150 1 150
5069 7/3/2002 18.605 400 2 800
5069 7/3/2002 18.605 400 1 400
5069 7/1/2002 18.605 400 2 800
5069 7/2/2002 1.86 40 8 320
I want to summarize the data to show three sums:
Total sum should be 2518.62
Partial sum based on BUV (unit value)
If BUV is 0 the Sum should be 48.62
If BUV is not 0 the Sum should be 2470.00
I have been trying to use Select statements such as this
Select BCCODE, 0,0,
Case When (BUV)=0 Then Sum(BQUAN * BPRICE) End
From bil
WHERE (BCCODE = '5069') AND (BDATE BETWEEN CONVERT(DATETIME, '2002-07-01 00:00:00', 102) AND CONVERT(DATETIME, '2002-07-07 00:00:00', 102))
GROUP BY BCCODE, BUV with Rollup
having (BUV)=0. This one gives me the correct answer when the BUV is 0.
BUUUUUUTTTTT.....
Select BCCODE, 0,
Case When BUV<>0 then SUM(BQUAN * BPRICE) End, 0
FROM bil
WHERE (BCCODE = '5069') AND (BDATE BETWEEN CONVERT(DATETIME, '2002-07-01 00:00:00', 102) AND CONVERT(DATETIME, '2002-07-07 00:00:00', 102))
GROUP BY BCCODE,BUV with Rollup
Having BUV<>0
Gives me three records, not one.
It would be nice to have these items in one record.
Any help would be appreciated.
Carolyn
I have the following table:
BCCODE BDATE BUV BPRICE BQUAN Ext. Price
5069 7/1/2002 0 0.11 62 6.82
5069 7/1/2002 0 1.1 38 41.8
5069 7/6/2002 6.977 150 1 150
5069 7/3/2002 18.605 400 2 800
5069 7/3/2002 18.605 400 1 400
5069 7/1/2002 18.605 400 2 800
5069 7/2/2002 1.86 40 8 320
I want to summarize the data to show three sums:
Total sum should be 2518.62
Partial sum based on BUV (unit value)
If BUV is 0 the Sum should be 48.62
If BUV is not 0 the Sum should be 2470.00
I have been trying to use Select statements such as this
Select BCCODE, 0,0,
Case When (BUV)=0 Then Sum(BQUAN * BPRICE) End
From bil
WHERE (BCCODE = '5069') AND (BDATE BETWEEN CONVERT(DATETIME, '2002-07-01 00:00:00', 102) AND CONVERT(DATETIME, '2002-07-07 00:00:00', 102))
GROUP BY BCCODE, BUV with Rollup
having (BUV)=0. This one gives me the correct answer when the BUV is 0.
BUUUUUUTTTTT.....
Select BCCODE, 0,
Case When BUV<>0 then SUM(BQUAN * BPRICE) End, 0
FROM bil
WHERE (BCCODE = '5069') AND (BDATE BETWEEN CONVERT(DATETIME, '2002-07-01 00:00:00', 102) AND CONVERT(DATETIME, '2002-07-07 00:00:00', 102))
GROUP BY BCCODE,BUV with Rollup
Having BUV<>0
Gives me three records, not one.
It would be nice to have these items in one record.
Any help would be appreciated.
Carolyn