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

  • SEARCH
  • Home
  • 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 4608506
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:51:17+00:00 2026-05-22T00:51:17+00:00

I am working on a sql view that should get the average number of

  • 0

I am working on a sql view that should get the average number of hits by hour of the day, regardless of what day/date it is for traffic monitoring (12:00:00.000 – 12:59:59.999). Any ideas?

EDIT

Now I have the total, how do I get the average? SELECT AVG(“FUNCTION BELOW”) DOES NOT WORK

SELECT     COUNT(*) AS total, DATEPART(hh, LogDate) AS HourOfDay
FROM         dbo.Log
GROUP BY DATEPART(hh, LogDate)
  • 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. Editorial Team
    Editorial Team
    2026-05-22T00:51:18+00:00Added an answer on May 22, 2026 at 12:51 am

    Convert to DATEPART(hh,…..

    Example SELECT DATEPART(hh,GETDATE())

    Since you are on SQL Server 2008, you can use the time data type, just convert to time

    example

    SELECT CONVERT(TIME,GETDATE())
    

    Then you can filter that also

    Since I am not sure what your output is supposed to be like I am showing you both, but if all you need is to group by hour, then just do a datepart(hh.....

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

Sidebar

Related Questions

I am trying to get this awesome JQuery plugin working with SQL Server. I
I am trying to view the entries into my sql database that were entered
I'm trying to get an ASP.NET MVC app working... I should have known it
I have a working sql query that I have been trying to convert to
Update I now have it working to an extent that the view is populated
I have a MS SQL database that I am working on, within this database
I am stuck figuring out a working SQL Query for the fallowing: I need
Added: Working with SQL Server 2000 and 2005, so has to work on both.
I'm working with SQL Server 2005 and Windows Server 2000 and wonder if there
I am working on sql server where i want to save html code into

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.