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
 Avoid Duplicate value and Get sum of Duplicate One

Author  Topic 

aoriju
Posting Yak Master

156 Posts

Posted - 2009-10-22 : 08:44:59
ID Name QTY Status
====================================
1 Test1 2.000 FALSE
2 Test2 2.000 FALSE
3 Test3 1.248 TRUE
4 Test4 1.818 TRUE
5 Test4 0.667 TRUE
6 Test5 0.667 TRUE

I want to get Sum with Avoid duplicate value

1 Test1 2.000 FALSE
2 Test2 2.000 FALSE
3 Test3 1.248 TRUE
4 Test4 2.481 TRUE
5 Test5 0.667 TRUE

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-10-22 : 08:50:38
select sum(distinct QTY) from <table_name>

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-10-22 : 08:50:54
select name,sum(qty) as qty,status from your_table
group by name,status

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

aoriju
Posting Yak Master

156 Posts

Posted - 2009-10-22 : 09:10:59
Not Working
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-10-22 : 09:13:40
quote:
Originally posted by aoriju

Not Working


Which query?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -