troubleshooting Question

SQL running total with count

Avatar of ginsburg7
ginsburg7 asked on
Microsoft SQL Server 2008
7 Comments1 Solution443 ViewsLast Modified:
I have the following data, which list part numbers, orders for those part numbers, and a field that lists the maximum number of orders I am allowed to have for those part numbers.  I'm looking for a result set that lists only the first 'x' number of orders for each part number based on the maximum number of orders allowed.  In other words, I want to see the first 2 orders for FUJI 2 and the first 4 orders for FUJI 3.  Thank you very much.

Part Number                     Order             Maximum Number of Orders Allowed
FUJI 2                              40099222      2
FUJI 2                              40099223      2
FUJI 2                              40099224      2
FUJI 2                              40099225      2
FUJI 2                              40099226      2
FUJI 3                              40099227      4
FUJI 3                              40099228      4
FUJI 3                              40099229      4
FUJI 3                              40099230      4
FUJI 3                              40099231      4
FUJI 3                              40099232      4
FUJI 3                              40099233      4
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros