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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:24:09+00:00 2026-06-08T21:24:09+00:00

I have something like this: SELECt * FROM ( SELECT prodid, date, time, tmp,

  • 0

I have something like this:

 SELECt *
   FROM (
        SELECT prodid, date, time, tmp, rowid
          FROM live_pilot_plant
         WHERE date BETWEEN CONVERT(DATETIME, '3/19/2012', 101)
           AND CONVERT(DATETIME, '3/31/2012', 101)
         ) b
  WHERE b.rowid % 400 = 0

FYI: The reason for the convert in the where clause, is because my date is stored as a varchar(10), I had to convert it to datetime in order to get the correct range of data. (I tried a bunch of different things and this worked)

I’m wondering how I can return the data I want every 4 hours during those selected dates. I have data collected approximately every 5 seconds (with some breaks in data) – ie data wasn’t collected during a 2 hour period, but then continues at 5 second increments.

In my example I just used a modulo with my rowid – and the syntax works, but as I mentioned above there are some periods where data isnt collected so using logic like: if you take data every 5 seconds and multiple that by 4 hours you can approximately say how many rows are in between wont work.

My time column is a varchar column and is in the form hh:mm:ss

My ideal output is:

  | prodid  | date       | time      |  tmp  |
  |    4    | 3/19/2012  | 10:00:00  |  2.3  |
  |    7    | 3/19/2012  | 14:00:24  |  3.2  |

As you can see I can be a bit off (in terms of seconds) – I more so need the approximate value in terms of time.

Thank you in advance.

  • 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-08T21:24:10+00:00Added an answer on June 8, 2026 at 9:24 pm

    This should work

    select prodid, date, time, tmp, rowid
    from live_pilot_plant as lpp
    inner join (
    
    select min(prodid) as prodid                     -- is prodid your PK?? if not change it to rowid or whatelse is your PK
        from live_pilot_plant
        WHERE date BETWEEN CONVERT(DATETIME, '3/19/2012', 101)  -- or whatever you want
                       AND CONVERT(DATETIME, '3/31/2012', 101)  -- for better performance it is on the inner select
        group by date, 
        floor(                                       -- floor makes the trick
        convert(float,convert(datetime, time))       -- assumes "time" column is a varchar containing data like '19:23:05'
        * 6                                          -- 6 comes form 24 hours / 4 hours
        )
    
    ) as filter on lpp.prodid = filter.prodid        -- if prodid is not the PK also correct here.
    

    A side note for everyone else who have date + time data in only one datetime field, suppose named “when_it_was”, the group by can be as simple as:

    group by floor(when_it_was * 6)                  -- again, 6 comes from 24/4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have something like this: $db=new PDO($dsn); $statement=$db->query('Select * from foo'); while
I have to write an query something like this select * from table where
I have a query something like this select emp from EMP emp where emp.
Let's say I have something like this: select sum(points) as total_points from sometable where
I have a simple MySQL query that looks something like this SELECT * FROM
I have something like this select A, B, C from tableA where A =
If I have a TTreeView, and I call something like this: myTreeView.Select(nodeIWantSelected); it gets
I have something like this: [{'date': 1, 'value':5}, {'date':2,'value':3}, ...] and want to map
I have something like this Select A.a, A.b, A.a+A.b as c, (A.a+A.b*2)+A.d as d
I want to write SQLite statement something like this: SELECT * FROM Table WHERE

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.