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.
| Author |
Topic |
|
vadmcse
Starting Member
10 Posts |
Posted - 2009-04-08 : 11:52:54
|
| Hi,I have a table with this fields and content:Total_____discount______ZIP8000________12_________080104500________12_________08010 3600________6__________080251200________12_________08025Now i have this query:SELECT (SUM (Total) + (SUM (Total)* ((Discount)/100))) AS TotAmt, ZIPFROM tableWHERE ZIP BETWEEN '08000' AND '08999'GROUP BY Discount, ZIPThe result is:12500_____080103600______080251200______08025I want to get this result:12500______080104800_______08025If i take the "Discount" off of the GROUP BY clause, i get an error.Any sugestion?Thanks |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2009-04-08 : 12:05:43
|
| [code]declare @yak table( total int, discount int, zip varchar(8))insert into @yak (total, discount, zip)select 8000,12,'08010' union all select4500,12,'08010' union all select3600,6,'08025' union all select1200,12,'08025' SELECT (SUM(Total) + (SUM ((Total)* ((Discount)/100)))) AS TotAmt, ZIPFROM @yakWHERE ZIP BETWEEN '08000' AND '08999'GROUP BY ZIP[/code][Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQL or How to sell Used CarsFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
vadmcse
Starting Member
10 Posts |
Posted - 2009-04-08 : 12:47:12
|
| YES!!! It worked!i can't believe i didn't see this.Thanks |
 |
|
|
|
|
|
|
|