Displaying * items along with total sum

  • Thread starter Thread starter naveen prasad
  • Start date Start date
N

naveen prasad

Dear all,
kindly solve my problem

I have created a table d1.

d1 fields, Id, date ,r1,r2 r1,r2 are numeric values only.

I want to get a result which will display all the details of the table
like for example result of select * from d1;
with the result I want in the sum of individual rows like sum(r1) ,sum(r2)
also to be diplayed in the last row.


like example d1 table if we consider r1,r2

20 25
15 15
10 10

now i want the result like below, all details along with sum at bottom

20 25
15 15
10 10

45 50


regards
 
Try this --
SELECT Id, date, r1, r2
FROM d1
UNION ALL SELECT Null, Null, Sum(r1) AS [XX], SUM(r2) AS [YY]
FROM d1;
 
Excellent dear your formula made my problem solved.

thanks alot for your kind response..


regards


KARL DEWEY said:
Try this --
SELECT Id, date, r1, r2
FROM d1
UNION ALL SELECT Null, Null, Sum(r1) AS [XX], SUM(r2) AS [YY]
FROM d1;

--
Build a little, test a little.


naveen prasad said:
Dear all,
kindly solve my problem

I have created a table d1.

d1 fields, Id, date ,r1,r2 r1,r2 are numeric values only.

I want to get a result which will display all the details of the table
like for example result of select * from d1;
with the result I want in the sum of individual rows like sum(r1) ,sum(r2)
also to be diplayed in the last row.


like example d1 table if we consider r1,r2

20 25
15 15
10 10

now i want the result like below, all details along with sum at bottom

20 25
15 15
10 10

45 50


regards
 
Back
Top