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
 General SQL Server Forums
 New to SQL Server Programming
 query help needed

Author  Topic 

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-09-16 : 10:51:27
hi all,

I have a table as below and I try to get out put as second table
can you help me in writing query for this.

select * from inv

cheque lineno inv_amt tax
x 1 100.00 0.00
y 3 200.00 0.00
x 0 0.00 10.00
y 0 0.00 20.00


I want out put to be as

cheque lineno inv_amt tax
x 1 100.00 10.00
y 3 200.00 20.00

Regard,
cse.

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-09-16 : 10:59:21
this?

select cheque,max([lineno]),sum(inv_amt),sum(tax) 
from inv
group by cheque
Go to Top of Page

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-09-16 : 11:47:11
thank you Vijay
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-09-16 : 11:53:33
ur welcome
Go to Top of Page
   

- Advertisement -