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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:53:20+00:00 2026-05-17T01:53:20+00:00

using MSQL 2005 I have a continuous set of flow measurements (averaged for each

  • 0

using MSQL 2005

I have a continuous set of flow measurements (averaged for each 15 minute time slice)

I am trying to write a query to find the minimum flow for each day and the time it occurs
Finding the minimum flow is easy but getting the time is harder.

Currently I do this:

select d1.data_point_groupid
     , min(d1.timeID) [timeId]
     , min(d1.[value]) [value] 
from dma.dbo.calculated_average_group_flow d1
where night=1 and round(d1.value, 6)=
(
    select round(min(value), 6)
     from dma.dbo.calculated_average_group_flow d2
     where night=1
        and d2.[date]=d1.[date]
        and d2.data_point_groupid=d1.data_point_groupid
)
group by d1.data_point_groupid, d1.date

However this will occasionally not match due to rounding errors

I have also tried using ranking but this is so slow I had to cancel the query

select [data_Point_GroupID], [date], [timeId], [value] from
    (
    select * , Rank() over (Partition BY data_Point_GroupID, [date] order by value ASC) as Rank
    from 
    [calculated_average_group_flow] d2
    ) d1
 WHERE rank=1

The calculated_average_group_flow is another view that does the averaging calculations

Is there a better way to do this?

  • 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-17T01:53:20+00:00Added an answer on May 17, 2026 at 1:53 am

    When comparing floating point, you need to use an epsilon (I used 1e-9 below) to avoid precision errors:

    select d1.data_point_groupid
         , min(d1.timeID) [timeId]
         , min(d1.[value]) [value] 
    from dma.dbo.calculated_average_group_flow d1
    where night=1 and 1e-9 >=
    (
        select abs(d1.value - min(d2.value))
         from dma.dbo.calculated_average_group_flow d2
         where night=1
            and d2.[date]=d1.[date]
            and d2.data_point_groupid=d1.data_point_groupid
    )
    group by d1.data_point_groupid, d1.date
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using InteliJ IDEA , I am trying to set up multiple projects to run
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
I have the following set of code: using (OracleConnection conn = new OracleConnection(m_fceConn)) {
Using PHP, for-each row in a MySQL query's result set, I need to execute
Using CI for the first time and i'm smashing my head with this seemingly
Using import datetime in python, is it possible to take a formatted time/date string
Using Microsoft SQL Server 2005, is there any way to see when a table
Using RestKit 0.10.1, I have objects served similar to this json format: {objects: [
If using the Ruby/MSQL library I returned an object of type Mysql::Result, how would
Using MVC2 I have an AJAX form which is posting to a bound model.

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.