=========
id units tag
1 2 x
1 3 x
1 10 y
2 5 x
2 5 x
2 2 x
3 10 y
3 3 x
3 1 y
=========
basiclly the goal is to sum up all the units which has same tag for each id
so that the output will be some thing like:
============
id units tag
1 5 x
1 10 y
2 12 x
3 11 y
3 3 x
============
i am supose to use simple queries to do this job, but i just have no idea how to
can any one give me an idea?
thanks
Quote:
Originally Posted by temptgan
if i have a table like this:
=========
id units tag
1 2 x
1 3 x
1 10 y
2 5 x
2 5 x
2 2 x
3 10 y
3 3 x
3 1 y
=========
basiclly the goal is to sum up all the units which has same tag for each id
so that the output will be some thing like:
============
id units tag
1 5 x
1 10 y
2 12 x
3 11 y
3 3 x
============
i am supose to use simple queries to do this job, but i just have no idea how to
can any one give me an idea?
thanks
select id,sum(units) as units,tag from table_above
group by id, tags|||
Quote:
Originally Posted by temptgan
if i have a table like this:
=========
id units tag
1 2 x
1 3 x
1 10 y
2 5 x
2 5 x
2 2 x
3 10 y
3 3 x
3 1 y
=========
basiclly the goal is to sum up all the units which has same tag for each id
so that the output will be some thing like:
============
id units tag
1 5 x
1 10 y
2 12 x
3 11 y
3 3 x
============
i am supose to use simple queries to do this job, but i just have no idea how to
can any one give me an idea?
thanks
select id,sum(units) as units,tag from table_above
group by id, tag
No comments:
Post a Comment