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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:58:34+00:00 2026-05-30T07:58:34+00:00

I have high frequency tick data which need to sort from microsecond to 6

  • 0

I have high frequency tick data which need to sort from microsecond to 6 seconds interval. The daily tick data start from 09:15:00.000 EST, and end at 15:15:00.000 EST.

This is my temp2 table:

 date1                       | close1 | volume1
-----------------------------+--------+---------
 2010-04-16 09:15:28.010 EST |  10001 |       4
 2010-04-16 09:16:00.020 EST |  10002 |       5
 2010-04-16 09:16:35.030 EST |  10003 |       6
 2010-04-16 09:16:35.040 EST |  10001 |       3
 2010-04-16 15:14:59.050 EST |  10007 |       3
 2010-04-19 09:15:05.050 EST |  10002 |       1
 ...                         |    ... |     ...

(date1 is a VARCHAR2(28); close1 and volume1 are both NUMBERs).

How do I get the following result?

 date2               | close2 | volume2
---------------------+--------+---------
 2010-04-16 09:15:30 |  10001 |       4
 2010-04-16 09:16:06 |  10002 |       5
 2010-04-16 09:16:36 |  10001 |       9
 2010-04-16 15:15:00 |  10007 |       3
 2010-04-19 09:15:06 |  10002 |       1
 ...                 |    ... |     ...

The close2 column use last_value of interval 00, 06, 12, 18, 24, 30, 36, 42, 48, 54. and if microseconds in range 00-05.999, just set close2 column value as last_vlue of the interval, set volume2 column value as sum of volume1 of the interval.

  • 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-30T07:58:35+00:00Added an answer on May 30, 2026 at 7:58 am

    Rather than packing all the logic into a single query — which is possible, but incredibly ugly and painful — I think it makes sense to create a stored-procedure that translates your date1 to your date2:

    CREATE OR REPLACE FUNCTION date1_to_date2 (date1 IN VARCHAR2) RETURN varchar2
    IS
    
      ts TIMESTAMP;
    
    BEGIN
    
      ts := TO_TIMESTAMP(SUBSTR(date1, 1, 19), 'YYYY-MM-DD HH24:MI:SS');
    
      IF SUBSTR(date1, 21, 3) > 0 THEN
        ts := ts + NUMTODSINTERVAL(1, 'SECOND');
      END IF;
    
      ts := ts + NUMTODSINTERVAL(MOD(60 - TO_CHAR(ts, 'SS'), 6), 'SECOND');
    
      RETURN TO_CHAR(ts, 'YYYY-MM-DD HH24:MI:SS');
    
    END date1_to_date2;
    /
    
    SHOW ERRORS;
    

    Then the rest, while not exactly straightforward, is nonetheless palatable:

    SELECT date2,
           close1 AS close2,
           volume2
      FROM ( SELECT date2,
                    close1,
                    ROW_NUMBER() OVER (PARTITION BY date2 ORDER BY date1 DESC) AS rn,
                    SUM(volume1) OVER (PARTITION BY date2) AS volume2
               FROM ( SELECT date1,
                             date1_to_date2(date1) AS date2,
                             close1,
                             volume1
                        FROM temp2
                    )
           )
     WHERE rn = 1
     ORDER BY date2
    ;
    

    (You can actually do it with just one subquery, by substituting the definition of date2 everywhere — and maybe even without any subquery at all, if the WHERE rn = 1 can be converted into a HAVING clause, which I didn’t try — but I think this is the clearest way.)

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

Sidebar

Related Questions

I need to create a server process which can push high frequency data (1000
We have an application where we need to de-serialize some data from one stream
I currently have an array full of data which from what I believe is
I suppose I could take a text and remove high frequency English words from
I am working with a system in which I am getting data from a
Say you need to have a list/array of integers which you need iterate frequently,
I have a system which requires I have IDs on my data before it
In the process industry, lots of data is read, often at a high frequency,
I have a COM (C++) API that listens for data updates from a server
My problem: i have many servers do caching data from key-value database. These caching

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.