Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

getting all the days of week eevn if data doesnt exist Expand / Collapse
Author
Message
Posted Friday, July 5, 2013 8:39 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, November 24, 2014 2:55 PM
Points: 301, Visits: 500
Hi,
I've tried this before but just not getting it... sorry..
I have an aux.date table with date info date, dayofweek, kindofday etc

I want to have a start and end date(using SSRS) to find recorded services
so lets say the put in 7/1/13 thru 7/5/13 and 7/4 is a holiday and no recorded services exist

I want output similar to:
date record serv KINDOFDAY
7/1/13 recservdata1 .. Weekday
7/1/13 recservdata2... WeekDay
7/2/13 recservdata3... Weekday
7/3/13 recservdata4... Weekday
7/4/13 NULL Holiday
7/5/13 recservdata5... Weekday
etc...


I have a view which grabs the days of the week (rpt_cal_Select)

then I attached to this but on get records with data...

SELECT dbo.RECORDED_SERVICE.SERVICE_ITEM_MONIKER, dbo.rpt_Cal_Select.Date AS Expr1, dbo.SERVICE_ITEM.Code, dbo.rpt_Cal_Select.*,
dbo.RECORDED_SERVICE.OID
FROM dbo.rpt_Cal_Select INNER JOIN
dbo.RECORDED_SERVICE ON dbo.rpt_Cal_Select.Date = DATEADD(dd, 0, DATEDIFF(dd, 0, dbo.RECORDED_SERVICE.STARTTIME)) LEFT OUTER JOIN
dbo.SERVICE_ITEM ON dbo.RECORDED_SERVICE.SERVICE_ITEM_MONIKER = dbo.SERVICE_ITEM.OID

Thanks
Joe


Post #1470770
Posted Friday, July 5, 2013 8:44 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, December 12, 2014 10:09 AM
Points: 2,876, Visits: 5,201
In order to display records for dates which are not found in the table you are reporting on, you should build you query based on your calendar table aux.date which then you should LEFT JOIN to the rest of tables.
You have providede too little information in order to write exact query you can use. If you need more help, please read the article from the link found at the bottom of my signature. It explains what is required in order to attract most relevant and prompt help.


_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1470772
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse