Clicky

i have table like

id name wef wee wes
1  xyz    23   34      45
1  sem   34   75      30
2  snp    11   23      21
3  por     12   22      32
3 sor      10  20      20
3   nor    12  23      23

i want
id   name   wef   wee   wes
1    xyz        23      34       45
      sem        34     75      30
     total        57    109     75
2    snp        11      23       21
3     por       12      22      32
      sor        10      20      20
      nor        12      23      23    
     total       34      65      75

asked 01/04/2011 07:50

priya171's gravatar image

priya171 ♦♦


4 Answers:
you won't have another row as with total but you can have the another column as total as below

select *, sum(wef) as weftotal,  sum(wee) as weetotal, sum(wes) as westotal from <yourtable> group by name;
link

answered

kalmax's gravatar image

kalmax

That can i do but i want total at row level. Thanks
link

answered 2011-01-05 at 04:04:56

priya171's gravatar image

priya171

and you want the ID only on the first row per group?
I would do that in the application coding ...

apart from that:
1:
2:
3:
4:
5:
select id, name,  wef , wee , wes from yourtable
union all
select id, 'total',  sum(wef) , sum(wee) , sum(wes) from yourtable group by id
order by 1
link

answered 2011-01-05 at 22:21:52

angelIII's gravatar image

angelIII

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

link

answered 2011-01-06 at 03:18:49

angelIII's gravatar image

angelIII

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×1

Asked: 01/04/2011 07:50

Seen: 181 times

Last updated: 12/17/2011 05:17

Categories