Include NULL Values - SQL Query

Discussion in 'microsoft.public.sqlserver.datamining' started by Stuart Troy, Jun 16, 2007.

  1. Stuart Troy

    Stuart Troy Guest

    Hi,

    My SQL query tells me the number of people in attendance, per day, for a
    specific date range.

    But my query doesn't return dates for those days with a null value (no
    people in attendance).
    So I have days missing (gaps) in my calendar.

    How can I modify my query to include every sequential date/date, even those
    with NULL values.

    Thanks
    Stuart Troy
    Sydney AUSTRALIA
     
    Stuart Troy, Jun 16, 2007
    #1
    1. Advertisements

  2. Stuart Troy

    Dejan Sarka Guest

    My SQL query tells me the number of people in attendance, per day, for a
    Why don't you create an auxiliary calendar table and then use left outer
    join from the calendar table to your attendance table? See this article for
    calendar auxiliary table:
    http://sqlserver2000.databases.aspf...nsider-using-an-auxiliary-calendar-table.html.
     
    Dejan Sarka, Jun 16, 2007
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.