chris123321
IS-IT--Management
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.
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.