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)
 sql query to find max of sum

Author  Topic 

just_a_kid83
Starting Member

1 Post

Posted - 2004-05-23 : 05:15:37
hi.. anyone know who to find the max after i sum up??
i have this query but it seems didnt work..
when i use max(sum(cc.quantity)) they said it violates the rules??
please help me...

select cc.isbn
from cart_contains cc,book bo,shopping_cart sc
where cc.cartId=sc.cartid
and cc.isbn=bo.isbn
and (sc.State='checked-out' OR sc.State='fulfilled')
group by cc.isbn
having sum(cc.quantity) > all
(
select sum(cc.quantity)
from cart_contains cc,book bo,shopping_cart sc
where sc.cartid=cc.cartid
and bo.isbn=cc.isbn
group by cc.isbn
)
)

God Bless u

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2004-05-23 : 09:39:41
[code]
select max(s) from
(select sum(c) as s
from ... ) as dt
[/code]
Go to Top of Page
   

- Advertisement -