Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

book dealing w/ this type of question

Status
Not open for further replies.

chris123321

IS-IT--Management
Mar 13, 2007
139
US
I had to write a query that would figure out the Amount depending on the order of Position Order and Priority.
Logically, I understood what I had to do in order to figure out the Numerator, but it took me some time to write the query.

CID NID Order Priority Amount Numerator
101 2001 1 1 1000 1000
101 2002 1 2 2000 3000
101 2003 5 1 1000 4000
101 2004 6 1 3000 7000

Per C-Id, the Order and Priority has to be looked at for each N-Id and for the highest Order I have to sum the highest order to the lowest order. And if the Order has the same values, then the Priority has to be looked at. For example, NID 2004 has Order 6 so the Numerator is (3000+1000+2000+1000). For NID 2002, the Order # is the same, but the priority is higher so the Numerator is 2000+1000.

What is the best way to become more experienced to writing these type of queries? Is there a financial sql server book that can be referred to?

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top