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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Returning dates without values

Author  Topic 

MaverickUK
Yak Posting Veteran

89 Posts

Posted - 2005-09-15 : 11:21:32
Hi guys

I am in a pickle of a bind here!
I'm extracting data from a table about the number of views a series of items have got between two dates.

The item ids are passed in as a comma delimited string, which then goes through split UDF, which turns it into a table. This table is then used to do an INNER JOIN.

A GROUP BY and COUNT(*) is used to group together views for each day, so the final data comes out in the correct format.

But then problem is, dates *without* any viewsjust don't appear in the result set.
What I need is for dates without any views to be returned with the number of views as 0.

I've attempted this using joins, but I can't seem to get the SQL working correcly.

Please can anyone point me in the right direction!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-09-15 : 12:50:24
Please post the code that you have tried.

Tara
Go to Top of Page

mmarovic
Aged Yak Warrior

518 Posts

Posted - 2005-09-15 : 12:50:33
Create a table (variable, temp table or even permanent one) with all dates from range you need and then do outer join.
Go to Top of Page
   

- Advertisement -