![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I need advice on how to approach this. To simplify with a sample, below is a list of various calculations based from ITEMS table: ITEM_NO FIELD_CALCULATION 123 cost*qty 111 cost-discount 222 sales*discount 333 cost-freight etc... There are 20 additional line items with different calculations. From my SP, how do I incorporate the above to say: SELECT ?? INTO #tmp1 FROM GL_ACCOUNT GL, ITEMS I WHERE GL.ITEM_NO = I.ITEM_NO TIA! Bob |
#3
| |||
| |||
|
|
Hi You could try something like: SELECT I.Item_No, CASE I.Item_No WHEN 123 THEN GL.cost*GL.qty WHEN 111 THEN GL.cost-GL.discount WHEN 222 THEN GL.sales*GL.discount WHEN 333 THEN GL.cost-GL.freight END AS [Calculation] FROM GL_ACCOUNT GL, JOIN ITEMS I ON GL.ITEM_NO = I.ITEM_NO John "B" <no_spam (AT) no_spam (DOT) com> wrote in message news:ZrydnROKGqA3psrfRVn-uQ (AT) rcn (DOT) net... I need advice on how to approach this. To simplify with a sample, below is a list of various calculations based from ITEMS table: ITEM_NO FIELD_CALCULATION 123 cost*qty 111 cost-discount 222 sales*discount 333 cost-freight etc... There are 20 additional line items with different calculations. From my SP, how do I incorporate the above to say: SELECT ?? INTO #tmp1 FROM GL_ACCOUNT GL, ITEMS I WHERE GL.ITEM_NO = I.ITEM_NO TIA! Bob |
#4
| |||
| |||
|
|
I was hoping to use the table created as a source without having to hardcode since it will be used by other SP. Thank you for your time. "John Bell" <jbellnewsposts (AT) hotmail (DOT) com> wrote in message news:42578d55$0$26738$db0fefd9 (AT) news (DOT) zen.co.uk... Hi You could try something like: SELECT I.Item_No, CASE I.Item_No WHEN 123 THEN GL.cost*GL.qty WHEN 111 THEN GL.cost-GL.discount WHEN 222 THEN GL.sales*GL.discount WHEN 333 THEN GL.cost-GL.freight END AS [Calculation] FROM GL_ACCOUNT GL, JOIN ITEMS I ON GL.ITEM_NO = I.ITEM_NO John "B" <no_spam (AT) no_spam (DOT) com> wrote in message news:ZrydnROKGqA3psrfRVn-uQ (AT) rcn (DOT) net... I need advice on how to approach this. To simplify with a sample, below is a list of various calculations based from ITEMS table: ITEM_NO FIELD_CALCULATION 123 cost*qty 111 cost-discount 222 sales*discount 333 cost-freight etc... There are 20 additional line items with different calculations. From my SP, how do I incorporate the above to say: SELECT ?? INTO #tmp1 FROM GL_ACCOUNT GL, ITEMS I WHERE GL.ITEM_NO = I.ITEM_NO TIA! Bob |
#5
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |