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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:07:54+00:00 2026-05-15T09:07:54+00:00

table1 -> id, time_stamp, value This table consists of 10 id’s. Each id would

  • 0

table1 -> id, time_stamp, value

This table consists of 10 id’s. Each id would be having a value for each hour in a day.
So for 1 day, there would be 240 records in this table.

table2 -> id

Table2 consists of a dynamically changing subset of id’s present in table1.

At a particular instance, the intention is to get sum(value) from table1, considering id’s only in table2,
grouping by each hour in that day, giving the summarized values a rank and repeating this each day.

the query is at this stage:

select time_stamp, sum(value),
rank() over (partition by trunc(time_stamp) order by sum(value) desc) rn
from table1
where exists (select t2.id from table2 t2 where id=t2.id)
and
time_stamp >= to_date('05/04/2010 00','dd/mm/yyyy hh24') and
time_stamp <= to_date('25/04/2010 23','dd/mm/yyyy hh24')
group by time_stamp
order by time_stamp asc

If the query is correct, can this be made more efficient, considering that, table1 will actually consist of thousand’s of id’s instead of 10 ?

EDIT: I am using sum(value) 2 times in the query, which I am not able to get a workaround such that the sum() is done only once. Pls help on 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-15T09:07:55+00:00Added an answer on May 15, 2026 at 9:07 am


    from table1
    where exists (select t2.id from table2 t2 where value=t2.value)

    The table2 doesn’t have Value field. Why is the above query with t2.Value?

    You could use a join here

    from table1 t1 join table2 t2 on  t1.id = t2.id
    

    EDIT: Its been a while that I worked on Oracle. Pardon me, if my comment on t2.Value doesn’t make sense.

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

Sidebar

Related Questions

I have a table in a MSSQL database that looks like this: Timestamp (datetime)
I have a sqlite (v3) table with this column definition: timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
i have a table named IMAGES in which there is attribute name img_ID which
I have a table, Table1, containing the fields TimeStamp and Humidity, which have the
I have a table that contains approx 10 million rows. This table is periodically
I have a mysql table that relies on the unix epoch time stamp equivalent
My table has a timestamp column named RowVer which LINQ maps to type System.Data.Linq.Binary.
How to create a table with a timestamp column that defaults to DATETIME('now') ?
Given an Oracle table created using the following: CREATE TABLE Log(WhenAdded TIMESTAMP(6) WITH TIME
I have a table that has a processed_timestamp column -- if a record has

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.