January 14, 2009 at 11:09 am
use tempdb
go
create table totalsum
(untiprice money null,
productoption int null)
insert into totalsum
values(200,1)
insert into totalsum
values(300,2)
insert into totalsum
values(400,3)
insert into totalsum
values(500,4)
insert into totalsum
values(600,5)
insert into totalsum
values(700,6)
I want to write a query which can give me the following result.
Sum(unitprice) productoption
2700 1
That means i need in first column sum of unitprice and second column only top productoption
Thanks help appreciated
January 14, 2009 at 11:32 am
How about:
select sum(UnitPrice), min(ProductOption)
from totalsum
Will that give you what you want?
Or, when you say "first", do you mean the lowest, or the one in the first row? What if the one in the first row was 7, and the one in the second row was 1, would you want a 7 or a 1 in your query?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply