473,326 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to retrive value for 12 hours

Hi,

I have table called CUSTOMER with the following fields and values

Interval_date rec_value
------------- ----------
10/1/2007 5:30:00 12.0
10/1/2007 6:00:00 17.0
10/1/2007 7:00:00 15.0
.
.
.
.
.
11/2/2007 5:30:00 18.0
11/2/2007 6:00:00 12.0
11/2/2007 6:30:00 21.0
11/2/2007 7:00:00 11.0

We have data in CUSTOMER table for every 30minutes.

My objective is to write a SQL query to retrieve the MININUM rec_value between 6:00:00PM(evening) on a given date untill 6:00:00AM the following morning

ex: 11/1/2007 6:00:00PM to 12/1/2007 6:00:00AM.

I have tried following query but din't work.

select interval_date min(rec_value)
from CUSTOMER
WHERE interval_date BETWEEN TRUNC(interval_date) +18/24 AND TRUNC(interval_date) +6/24
GROUP BY interval_date;

Any clue as to how we can use date along with timestamp?

Your prompt reply is greatly appreciated.


Thanks & Regards
Naveen
Feb 15 '08 #1
1 1333
amitpatel66
2,367 Expert 2GB
Hi,

I have table called CUSTOMER with the following fields and values

Interval_date rec_value
------------- ----------
10/1/2007 5:30:00 12.0
10/1/2007 6:00:00 17.0
10/1/2007 7:00:00 15.0
.
.
.
.
.
11/2/2007 5:30:00 18.0
11/2/2007 6:00:00 12.0
11/2/2007 6:30:00 21.0
11/2/2007 7:00:00 11.0

We have data in CUSTOMER table for every 30minutes.

My objective is to write a SQL query to retrieve the MININUM rec_value between 6:00:00PM(evening) on a given date untill 6:00:00AM the following morning

ex: 11/1/2007 6:00:00PM to 12/1/2007 6:00:00AM.

I have tried following query but din't work.

select interval_date min(rec_value)
from CUSTOMER
WHERE interval_date BETWEEN TRUNC(interval_date) +18/24 AND TRUNC(interval_date) +6/24
GROUP BY interval_date;

Any clue as to how we can use date along with timestamp?

Your prompt reply is greatly appreciated.


Thanks & Regards
Naveen
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT select interval_date min(rec_value)
  3. from CUSTOMER
  4. WHERE TO_CHAR(interval_date,'DD/MM/YY HH12:MI:SS PM') BETWEEN TO_DATE('11/01/2007 06:00:00 PM','DD/MM/YYYY HH12:MI:SS PM') AND TO_DATE('11/02/2007 06:00:00 AM','DD/MM/YYYY HH12:MI:SS PM')
  5.  
  6.  
Feb 15 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Allan | last post by:
I use select @@identity to return @@identity from my store procedure, but I could not retrive it from my Visual basic code, like variable= oRS.fields.item(0).value, it always says item can not be...
2
by: Goran | last post by:
I'm a student and I've just started to learn Visual Studio.NET. I have a project to make a web application. I have a problem to connect to the database and retriving the PassType of the...
1
by: TdarTdar | last post by:
Hello, what is the code to get the running applications "ApplicationId" Thanks Tdar
2
by: Gian Paolo | last post by:
Hi all on .net 2.0 i have a dataset and a table with some rows. Is there a way to retrive the current row index ? So i can retrive other value of that column... something like...
0
by: avishekb | last post by:
can anyone suggest me how to retrive data from a xml file using c/c++. for example: <schema> <applt to>portno</applyto> <type>int</type> <value>8080</value> </schema> i want to retrive the...
0
nehashri
by: nehashri | last post by:
hi, I need one help regarding Asp with MsAccess database. Problem. ======== i want to retrive stored image from the MSAccess database using asp.
2
idsanjeev
by: idsanjeev | last post by:
hello how can retrive the input text after submit button pressed and report a error message. i wants to post topic and if any error message is occured then retrive the inputed text but it forget its...
1
idsanjeev
by: idsanjeev | last post by:
hello i wants to retrive data in textarea like input text but in textarea value is not work so what should be use to retrive textarea value after any error <input type="text" name="name"...
10
by: arial | last post by:
Hi all, I need some help on retrive the value from query string. I have two web forms. One has the datagridview which displays the data from database. On one of the column I made a hyperlink to...
1
by: abirami elango | last post by:
Hi, i have created a web application in vb.net. i have assigned a value to the textbox during page UNLOAD event as below.. ......... Protected Sub Page_Unload(ByVal sender As Object, ByVal e As...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.