Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Monday, November 25, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Reporting & Notification Forums - Reporting
Forum to discuss reports for SalesLogix including Crystal, SQL Reports, etc. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to Reporting | New ThreadView:  Search:  
 Author  Thread: How to generate missing dates in SELECT?
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
How to generate missing dates in SELECT?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Dec 08 12:31 PM
I am using the history table which has data for many users who may or may not have history entered for a particular day.

What I need to do is show by user ALL weekday dates and the number of activities the user has completed. The problem is showing dates where no tasks have been completed. I need to show 0 for days that don't have history. As it is, the date is missing and averages are not being calculated properly on the report.

Is there a way to include all weekday dates using a SELECT even when there is no data for that date?

If more explanation is needed please let me know.

Thanks,
John G.
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: How to generate missing dates in SELECT?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Dec 08 1:57 PM
I think I found my answer in the form of something called a 'Tally' table. Someone at www.sqlservercentral.com provided this info and article link. It's very ingenious and can be used for more than just supplying missing dates. In cases like when used in place of a loop there is a significant performance increase.

Here is the article:
http://www.sqlservercentral.com/articles/TSQL/62867/

John G.
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: How to generate missing dates in SELECT?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Dec 08 2:01 PM
This common problem is a nasty one. Here are a couple of approaches:

1. Create a table that contains a record for each work day. This can act as your base table to ensure you get a result for each day

2. If the report is always run by week, create a sub report for each work day (5 I suppose). Your main report will need to pass the date range and userid to each sub report

Neither of these are ideal. Reporting on non existent data is a real pain.

Timmus
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: How to generate missing dates in SELECT?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Dec 08 2:04 PM
Timmus,

I suppose we were posting at the same time. Read my reply right before yours about Tally tables. This is the answer I was looking for and I think it will be for you too.

John G.
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: How to generate missing dates in SELECT?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Dec 08 2:10 PM
Jinx! Yes the tally table and the table containing work days is an identical concept. Good luck!

Timmus
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/25/2024 6:48:32 AM