February 16, 2007 at 10:45 am
Hello All,
I have a table say tableA. In this table i have a field called order_type which can have one of the following 3 values 'B','R',NULL. The other fields that will be used from this table are order_number and date_entered.
My requirement is to create a report based on the backorders and reship pecentage on a weekly basis for the entire year. The formula that will go on the report is as following-
(no. of order_type='B'/no. of order_type=NULL)*100
(no. of order_type='R'/no. of order_type=NULL)*100
For this requirement i have to create a dataset to have the fields say B(for backorder),R(for reships) and N(for total orders) based on weeks for each month.
I am not sure how i can create a dataset with all the 3 values for B,R and N available based on the dates.
Once this dataset is available it's very easy to create the report.
Any help will be appreciated.
February 19, 2007 at 8:00 am
This was removed by the editor as SPAM
February 19, 2007 at 5:07 pm
Sounds a lot like homework... What have you tried?
--Jeff Moden
Change is inevitable... Change for the better is not.
February 19, 2007 at 6:08 pm
I created views and then did joins on the combination of views and was able to achieve what i wanted .....but was wondering if there is any quicker,efficient way to achieve the same.
Thanks
February 20, 2007 at 7:05 am
Sure there is... is Table "A" the only table you need to draw from? Also, can you type up an example of what you'd like the output to look like?
--Jeff Moden
Change is inevitable... Change for the better is not.
February 27, 2007 at 8:14 am
One approach is to create a date table (or table variable) and do a join against it. I have used a table valued function to create a table variable with the begin and end dates of every month for a 5 year span and then joined a table against it using BETWEEN
select * from table A
inner join dateTable d on A.enteredDate between d.begDate and d.endDate
Not the most efficient query, but it worked for me against a table with 2m rows.
HTH
John Deupree
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply