Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
netsports
Starting Member
11 Posts |
Posted - 2005-08-11 : 15:57:51
|
| Instead of showing a vast amount of code and having viewers disect it, i think I should explain my problem and what I have to accomplish (along with the design idea of an adhoc query) instead of continuing to post code and saying "help." I have a .net datagrid where i have sales results for each sale (and a salesperson that the sale was made by) to display for a day in the past that is queried by the user. Besides the salesamount for the given day, I need to show salesamount results from the previous day next to the salesamount for the present day. All the table joins (2 of them) I'm using have been verified as correct. In my WHERE clause, I will include an OR operator to include both day's data:WHERE b.theDate = '" + requestedday + "' OR b.theDate = '" + daybefore + "'whereas the day before data in c# has been configured to represent whatever the date before the queried date is. I need to assign the salesrep's previous day's salesamount an alias so I can use it in my display, and that previous day's salesamount has to be related to the sales person.I've tried CASE WHEN statement, which i'm having trouble parsing the salesamount from the previous day by the salesrep. It seems this may be more than an adhoc query. Would would be the premise to create a VIEW, STORED PROCEDURE or TRIGGER for this, if I can't do an adhoc query to accomplish this?thanks in advance for any helpnetsports |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|