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 6157185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:44:32+00:00 2026-05-23T20:44:32+00:00

I have few tables that gather data for internal use but i want to

  • 0

I have few tables that gather data for internal use but i want to write all data to other table from which i can easily query statistical data without joins, group by and other mess. This select insert query will be run as maintenance plan each 10 minutes.

I have 3 tables with data

Visitors (id int, siteID int, date smalldatetime, isRead bit, isActive bit)
VisitorLastLocation (id int, visitorID int, siteID int, durationInSeconds int)
VisitorLocations(visitorLastLocationID int)

new item is added to Visitors table each time unique visitor comes to certain site, same goes for VisitorLastLocation. Next visit of already existing Visitor adds previous location to VisitorLocations and updates VisitorLastLocation table.

I need to fill this table each 10 minutes.

VisitorStatistics(id int, siteID int, visits int, pageViews int, isReadNumber int, isActiveNumber int, durationSum int, date smalldatetime)

So if you get me right i need to group by each selection by raw date (ie. 2/2/11 13:30 and not 2/2/11 13:31) and by siteID.

How would you advice to solve this, full solution will be very helpful…

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. Editorial Team
    Editorial Team
    2026-05-23T20:44:33+00:00Added an answer on May 23, 2026 at 8:44 pm

    From your description, all you are missing is the code to round a DATETIME to the lower 30 minute interval. DATEDIFF and DATEADD should help you here…

    GROUP BY
      DATEADD(MINUTE, DATEDIFF(MINUTE, 0, [date]) - (DATEDIFF(MINUTE, 0, [date]) % 30), 0),
      siteID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have multiple queries that query data from a few tables linked through
I have a remote mySQL table that I use in a few tools, occasionally
I have a few tables: DCDetails table which contains the Master data for a
I have a few tables that reference the same table. For example: Person has
I have a few tables that I'm trying to join together, but I can't
I've got a few tables that all have the same column domainID which basically
I have a few tables that have similar fields but not exactly the same.
I have a few different tables that I want to display vertically down a
I have few DB tables, witch are build using inheritance from one table witch
I am working with a few legacy tables that have relationships, but those relationships

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.