Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 166201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:03:23+00:00 2026-05-11T12:03:23+00:00

I feel like I’ve seen this question asked before, but neither the SO search

  • 0

I feel like I’ve seen this question asked before, but neither the SO search nor google is helping me… maybe I just don’t know how to phrase the question. I need to count the number of events (in this case, logins) per day over a given time span so that I can make a graph of website usage. The query I have so far is this:

select     count(userid) as numlogins,     count(distinct userid) as numusers,     convert(varchar, entryts, 101) as date  from     usagelog  group by     convert(varchar, entryts, 101) 

This does most of what I need (I get a row per date as the output containing the total number of logins and the number of unique users on that date). The problem is that if no one logs in on a given date, there will not be a row in the dataset for that date. I want it to add in rows indicating zero logins for those dates. There are two approaches I can think of for solving this, and neither strikes me as very elegant.

  1. Add a column to the result set that lists the number of days between the start of the period and the date of the current row. When I’m building my chart output, I’ll keep track of this value and if the next row is not equal to the current row plus one, insert zeros into the chart for each of the missing days.
  2. Create a ‘date’ table that has all the dates in the period of interest and outer join against it. Sadly, the system I’m working on already has a table for this purpose that contains a row for every date far into the future… I don’t like that, and I’d prefer to avoid using it, especially since that table is intended for another module of the system and would thus introduce a dependency on what I’m developing currently.

Any better solutions or hints at better search terms for google? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:03:23+00:00Added an answer on May 11, 2026 at 12:03 pm

    Frankly, I’d do this programmatically when building the final output. You’re essentially trying to read something from the database which is not there (data for days that have no data). SQL isn’t really meant for that sort of thing.

    If you really want to do that, though, a ‘date’ table seems your best option. To make it a bit nicer, you could generate it on the fly, using i.e. your DB’s date functions and a derived table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 76k
  • Answers 76k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer If the Domain Model requires relationships to be enforced then… May 11, 2026 at 3:02 pm
  • added an answer Actually I used VLC for the streaming.... Actually I just… May 11, 2026 at 3:02 pm
  • added an answer Please look at http://wiki.dvdlookup.org/index.php?title=Disc_Identification May 11, 2026 at 3:02 pm

Related Questions

I feel like I should know this, but I haven't been able to figure
I feel like I'm missing a fairly fundamental concept to WPF when it comes
I feel like I'm re-inventing the wheel here, but I need to find a
I feel like i am completely missing something because I am not able to
I feel like I am always reinventing the wheel for each application when it

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.