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)
 Easiest way to return at total?

Author  Topic 

mark1504
Posting Yak Master

103 Posts

Posted - 2004-05-27 : 09:10:39
I want to return a SELECT list consisting of various columns including a numeric one (the Invoice total).

How do I get the total showing on the bottom line?

Thanks in anticipation
Mark

rihardh
Constraint Violating Yak Guru

307 Posts

Posted - 2004-05-27 : 09:18:30
Why would someone want to do something like that? Make a simple SELECT on the server and save the total line for the client (GUI) side.
Go to Top of Page

Pethron
Starting Member

10 Posts

Posted - 2004-05-27 : 09:23:36
You could do it with a UNION SELECT in with you set the sum([numeric collumn])for the total and NULL for the others.
But summize the total on Clientside is cleaner, I think...
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-05-27 : 09:23:43
select 1 as sortcol, col1, col2, col3, InvTotal
from Invoices
union
select 2 as sortcol, 'Total', 'Total', 'Total', SUM(InvTotal)
from Invoices
order by 1

Duane.
Go to Top of Page

mark1504
Posting Yak Master

103 Posts

Posted - 2004-05-27 : 09:47:30
UNION! I haven't used that before. An simple and direct solution. Thanks ditch and Pethron.
Go to Top of Page
   

- Advertisement -