Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 22nd, 2005, 01:59 PM
joegaber joegaber is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 1 joegaber User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 24 sec
Reputation Power: 0
Question counting records in a specific time block per day

I have a scenario where I need to find the number of records in a table called 'DEALS', for a specific time frame (in this case 8am until 9am where the date field stores dates in the following format '06/01/2005 08:23:35'). I need to run this query to include each business day between two dates (ie., june 1, 2005 until current_date).

In addition, this query has to take into account only Users that are ACTIVE in a second table called 'DEALUSERS'

I have worked out the following to get the overall record set, but it is not narrowed down to just the specified time frame, nor does it produce the count for each day's 8:00-9:00 time frame.

SELECT fdls.DEALDATE, user.USERROLE
FROM DEALS dls, DEALUSER user
WHERE dls.CLIENTUSERID = user.USERID
AND user.STATUS = 'ACTIVE'
AND dls.PROXYTRADEFLAG = 'YES'
AND dls.MODENAFLAG = 'YES'
AND TRUNC(dls.DEALDATE)
BETWEEN TO_DATE('06/01/2004 08:00:00', 'MM-DD-YYYY HH:MI:SS')
AND current_date


I tried using the following at the end of the above query, but it doesn't work - any ideas?
AND TO_CHAR(EXTRACT('HOUR' FROM DEALTS)) = '8'

Can someone help, pls

Reply With Quote
  #2  
Old June 23rd, 2005, 10:31 AM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,308 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 6 h 19 m 24 sec
Reputation Power: 48
try:
Code:
SELECT 
     dls.DEALDATE, user.USERROLE
FROM 
     DEALS dls, DEALUSER user
WHERE 
     dls.CLIENTUSERID = user.USERID
 AND user.STATUS = 'ACTIVE'
 AND dls.PROXYTRADEFLAG = 'YES'
 AND dls.MODENAFLAG = 'YES'
 AND dls.DEALDATE
 BETWEEN 
        TO_DATE('06/01/2004 08:00:00', 'MM-DD-YYYY HH24:MI:SS')
    AND TO_DATE('06/01/2004 21:00:00', 'MM-DD-YYYY HH24:MI:SS');

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > counting records in a specific time block per day


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT