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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:42:55+00:00 2026-06-17T14:42:55+00:00

I am using SQL Server 2008 R2 Standard and I still very new to

  • 0

I am using SQL Server 2008 R2 Standard and I still very new to SQL Server.

I am trying to find when a x (measurement) has trend data that flatlines for longer than 48 intervals of the date time.

Thanks in advance.

My base query structure is

SELECT sites.site_name, 
       measurements.measurement_name, 
       trend_data_temp.trend_data_avg, 
       trend_data_temp.trend_data_time 
FROM   sites 
       INNER JOIN group_sites 
               ON sites.site_id = group_sites.site_id 
       INNER JOIN groups 
               ON group_sites.group_id = groups.group_id 
       INNER JOIN measurements 
               ON sites.site_id = measurements.site_id 
       INNER JOIN trend_data 
               ON measurements.measurement_id = trend_data.measurement_id 
       INNER JOIN trend_data_temp 
               ON measurements.measurement_id = trend_data_temp.measurement_id 
GROUP  BY sites.site_name, 
          measurements.measurement_name, 
          trend_data_temp.trend_data_avg, 
          trend_data_temp.trend_data_time 
ORDER  BY sites.site_name, 
          measurements.measurement_name 
  • 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-06-17T14:42:56+00:00Added an answer on June 17, 2026 at 2:42 pm

    slightly in the dark without any outlines of input data and output data but maybe you need something like this (not tested)

       SELECT 
               sites.site_name, 
               measurements.measurement_name, 
               trend_data_temp.trend_data_avg, 
               [occurances] = count(trend_data_temp.trend_data_time) 
        FROM   sites 
               INNER JOIN group_sites 
                       ON sites.site_id = group_sites.site_id 
               INNER JOIN groups 
                       ON group_sites.group_id = groups.group_id 
               INNER JOIN measurements 
                       ON sites.site_id = measurements.site_id 
               INNER JOIN trend_data 
                       ON measurements.measurement_id = trend_data.measurement_id 
               INNER JOIN trend_data_temp 
                       ON measurements.measurement_id = trend_data_temp.measurement_id 
        GROUP  BY 
               sites.site_name, 
               measurements.measurement_name, 
               trend_data_temp.trend_data_avg
        HAVING count(trend_data_temp.trend_data_time) >=48
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to SQL Server. I am trying to determine the best
We are using SQL Server 2008 R2 Standard and linked servers to get information
I am using SQL Server 2008 R2 Standard (version 10.50.1600.1) for my production website
Using SQL Server 2008, I am trying to figure out how to create a
I have a synchronous mirroring environment with automatic fail-over using sql server 2008 standard
I've inherited a working Oracle (10g) to SQL Server 2005 data replication using standard
Using SQL Server 2008, I am trying to do a left join between table
I've an event-driven app that has recently started using SQL Express 2008 (instead of
I am running SQL Server Reporting Services on SQL Server 2008 Standard and trying
Been using the new SQL 2012 Data Tools > SQL Server Database Project in

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.