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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:14:06+00:00 2026-06-08T20:14:06+00:00

My table looks like this: Table 1: Note: This table is very large in

  • 0

My table looks like this:

Table 1:
Note: This table is very large in reality, with lots more columns (20ish) and rows (in the millions)

 |  Time      |  tmp   |  productionID  |
 |  10:00:00  |   2.2  |    5           |
 |  10:00:05  |   5.2  |    5           |
 |  10:00:11  |   7.4  |    5           |
 |  ......    |   3.2  |    5           |
 |  10:10:02  |   4.5  |    5           |

Note: Timeis a varchar, so I assume I need to do something like this:

 CONVERT(VARCHAR(8), DATEADD(mi, 10, time), 114)

What I need to do is:

 select time, tmp 
 from mytable
 where productionid = somevalue 
 and time = first_time_stamp associated to some productionID(ie. 10:00:00 table above)
     time = 10 minutes after the first_time_stamp with some productionID
     time = 20 minutes after the first_time_stamp with some productionID
     ...25, 30, 40, 60, 120, 180 minutes 

I hope this makes sense. I’m not sure what the right way to do this is. I mean I thought of the following proccess:
-select first time stamp (with some productionID)
-add 10 minutes to that that time,
-add 20 minutes etc.. then use a pivot table and use joins to link to table 1
There must be an easier way.

Thank you in advance for the expertise.

Sample output expected:

    |  Time    | tmp
    | 10:00:00 | 2.2 
    | 10:10:02 | 4.5
    | 10:20:54 | 2.3 
    | 10:30:22 | 5.3
  • 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-08T20:14:08+00:00Added an answer on June 8, 2026 at 8:14 pm

    If you create an interval table on-the-fly and cross join it with starting time for each ProductionID, you can extract records fromMyTable falling in the same category and choose to retrieve only the first one.

    ; with timeSlots (startSlot, endSlot) as (
      select 0, 10
      union all
      select 10, 20
      union all
      select 25, 30
      union all
      select 30, 40
      union all
      select 40, 60
      union all
      select 60, 120
      union all
      select 120, 180
    ),
    startTimes (ProductionID, minTime) as (
      select ProductionID, min([Time])
        from MyTable
       group by ProductionID
    ),
    groupedTime (ProductionID, [Time], [Tmp], groupOrder) as (
      select myTable.ProductionID,
             myTable.Time,
             myTable.Tmp,
             row_number () over (partition by myTable.productionid, timeSlots.startSlot
                               order by mytable.Time) groupOrder
        from startTimes
       cross join timeslots
       inner join myTable
          on startTimes.ProductionID = myTable.ProductionID
         and convert(varchar(8), dateadd(minute, timeSlots.startSlot, convert(datetime, startTimes.MinTime, 114)), 114) <= mytable.Time
         and convert(varchar(8), dateadd(minute, timeSlots.endSlot, convert(datetime, startTimes.MinTime, 114)), 114) > myTable.Time
    )
    select ProductionID, [Time], [Tmp]
      from groupedTime
     where groupOrder = 1
    

    Sql Fiddle here.

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

Sidebar

Related Questions

My table looks like this. Location Head Id IntTime 1 AMD 1 1 2
My table looks like this (and I'm using MySQL): m_id | v_id | timestamp
My source table looks like this Id StartDate 1 (null) 2 12/12/2009 3 10/10/2009
If my table looks like this: CREATE TABLE `daily_individual_tracking` ( `daily_individual_tracking_id` int(10) unsigned NOT
I have two tables Department and Employee . Department table looks like this: ID
I have a table that looks like this: id value AGA 0.211 AGA 0.433
I have a table that looks like this: CREATE TABLE foobar ( id SERIAL
I have a table that looks like this: ID (pk,int) Col1 (nvarchar) Col2 (nvarchar)
I have a table that looks like this Id FirstName 5 Adam 6 Bob
I have a table that looks like this: table name: uno str_id | title

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.