SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


getting all the days of week eevn if data doesnt exist


getting all the days of week eevn if data doesnt exist

Author
Message
jbalbo
jbalbo
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1503 Visits: 688
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
Eugene Elutin
Eugene Elutin
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12728 Visits: 5478
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!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search