Hi All,
I am trying to create a report, for which I need suggestions to write the query.
I have a table1 which is shown below. Below that are month1 and month2 which are the reports I want to create, I have left the last column empty, which should be filled.
If you see the table1, for the same "style1" dutypaid value is different(3,1,2). I want to use up the highest paid first for the report. Let's say "Style1" "50" qty has been exported, for that I want to use "3" as duty paid first, then there will be 150 qty remaining in the table1 for me to use in the future months. How can I do this? Should I have another column which subtracts the Qty once used up? When it becomes zero, how can I select the next highest paid. What is the best way to do this, stored procedure, simple query with TOP and asc and desc order, cursors??? or DTS packages?
Any suggestion is helpful.
Table1
-----------------------------------------------
Style QtyImported DutyPaid
-----------------------------------------------
Style1 200 3
Style1 300 1
Style1 250 2
Style2 300 2
Style3 200 3
Style3 100 4
------------------------------------------------
Month 1 Report
------------------------------------------------------
Style QtyExported Dutydrawback(dutypaid*QtyExp)
-------------------------------------------------------
Style1 50
Style2 40
Style3 250
----------------------------------------------------
Month 2 Report
----------------------------------------------------
Style QtyExported Dutydrawback
-----------------------------------------------------
Style1 40
Style3 20
------------------------------------------------------
Thank you,
Shal
I am trying to create a report, for which I need suggestions to write the query.
I have a table1 which is shown below. Below that are month1 and month2 which are the reports I want to create, I have left the last column empty, which should be filled.
If you see the table1, for the same "style1" dutypaid value is different(3,1,2). I want to use up the highest paid first for the report. Let's say "Style1" "50" qty has been exported, for that I want to use "3" as duty paid first, then there will be 150 qty remaining in the table1 for me to use in the future months. How can I do this? Should I have another column which subtracts the Qty once used up? When it becomes zero, how can I select the next highest paid. What is the best way to do this, stored procedure, simple query with TOP and asc and desc order, cursors??? or DTS packages?
Any suggestion is helpful.
Table1
-----------------------------------------------
Style QtyImported DutyPaid
-----------------------------------------------
Style1 200 3
Style1 300 1
Style1 250 2
Style2 300 2
Style3 200 3
Style3 100 4
------------------------------------------------
Month 1 Report
------------------------------------------------------
Style QtyExported Dutydrawback(dutypaid*QtyExp)
-------------------------------------------------------
Style1 50
Style2 40
Style3 250
----------------------------------------------------
Month 2 Report
----------------------------------------------------
Style QtyExported Dutydrawback
-----------------------------------------------------
Style1 40
Style3 20
------------------------------------------------------
Thank you,
Shal