Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Simple select with a Total

Author  Topic 

davidliv
Starting Member

45 Posts

Posted - 2004-05-22 : 14:46:34
I must be tired, because I can't find an answer to my problem. I must be making things difficult.

I have a table which will return 3 records base on a typeID. I need to list those 3 records and provide a 4th row with a total.

RecID..TypeName..Amount
..1.....Style1....100
..2.....Style2....400
..3.....Style3....200
Total.............700

I want to present the "name" of my Type, but set my order by to the typeID.

kselvia
Aged Yak Warrior

526 Posts

Posted - 2004-05-22 : 15:07:17
Try this. modify for your specific typeid where clause

select recid, typename, amount
from table
where typeid = 2
union
select null, 'Total', sum(amount) amount --recid will be null for total line. Change to suit
from table
where typeid = 2
Go to Top of Page

davidliv
Starting Member

45 Posts

Posted - 2004-05-22 : 15:14:12
most excellent. This is exactly what I was looking for.
Go to Top of Page
   

- Advertisement -