Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft SQL Server > Get rows whose ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 10977 of 11431
Post > Topic >>

Get rows whose sum matches a value

by Mario Blataric <mario.blataric@[EMAIL PROTECTED] > Apr 17, 2008 at 01:28 PM

This should be simple, but I can't work it out without cursors.

 I have a table with quantity field. I want to get all first rows
whose sum of quantity matches defined value.

No    Quantity
=============
1       50
2       50
3       80
4       80
5       80
6       50

If defined value is, lets say, 180, query should return rows 1..3
Something like
select *
from table
where sum(quantity) = 180
order by No

Any way to work this out?

Thanks,

Mario B.
 




 6 Posts in Topic:
Get rows whose sum matches a value
Mario Blataric <mario.  2008-04-17 13:28:16 
Re: Get rows whose sum matches a value
"Plamen Ratchev"  2008-04-17 17:17:23 
Re: Get rows whose sum matches a value
Mario Blataric <mario.  2008-04-17 23:15:42 
Re: Get rows whose sum matches a value
"Plamen Ratchev"  2008-04-18 08:42:41 
Re: Get rows whose sum matches a value
--CELKO-- <jcelko212@[  2008-04-18 07:30:28 
Re: Get rows whose sum matches a value
Mario Blataric <mario.  2008-04-20 02:37:42 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Oct 15 13:33:41 CDT 2008.