Home » SQL & PL/SQL » SQL & PL/SQL » fetching evenly distributed records throughout the day (oracle 9i)
fetching evenly distributed records throughout the day [message #398820] Fri, 17 April 2009 14:56 Go to next message
techluver
Messages: 16
Registered: May 2006
Junior Member
Hello,
Lets say I have table with time_id(custom conversion of date time value)column and 30 million records in it. I would like to fetch 5000 records evenly distributed records throughout the day. How can we do this in sql?

Thanks for the help.
Re: fetching evenly distributed records throughout the day [message #398821 is a reply to message #398820] Fri, 17 April 2009 15:05 Go to previous messageGo to next message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
What does this time_id look like?

In any event, with the lack of information provided, I would say look at the Oracle SAMPLE clause in combination with the WHERE clause.
Re: fetching evenly distributed records throughout the day [message #398822 is a reply to message #398820] Fri, 17 April 2009 15:06 Go to previous messageGo to next message
BlackSwan
Messages: 25041
Registered: January 2009
Location: SoCal
Senior Member
When all else fails, RTFM
http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_103a.htm#2065954


You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
Please, please, please Read & Follow Posting Guidelines above.
Go to the section labeled "Practice" & do as directed.
Re: fetching evenly distributed records throughout the day [message #398824 is a reply to message #398821] Fri, 17 April 2009 16:02 Go to previous messageGo to next message
techluver
Messages: 16
Registered: May 2006
Junior Member
thanks for the reply.
time id is unique integer value assigned to each second of the day.
Ex:
9:00:00AM - 1
9:00:01 - 2
9:00:02 - 3
etc..
Re: fetching evenly distributed records throughout the day [message #398830 is a reply to message #398820] Sat, 18 April 2009 00:37 Go to previous message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
There are 86400 seconds in a day.
You want 5000 records.
Take a record every 86400/5000=17 seconds: 0:00:00, 0:00:17...

Regards
Michel
Previous Topic: UTL_FILE file open modes
Next Topic: Find maximum number by using while loop ??
Goto Forum:
  


Current Time: Tue Dec 06 12:29:59 CST 2016

Total time taken to generate the page: 0.07416 seconds