| | |
SQL Script help
Please support our Oracle advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2007
Posts: 1
Reputation:
Solved Threads: 0
I've created a sql statement that I'm try get the number of messages that will expire during a certain time period. I'm looking to purge messages according to mm/dd/yyyy. I'm having a world of difficulty figuring the statement format out assistence would be appriciate.
SQL script:
select originationtime, expirationtime, ((TO_DATE('01/01/1970', 'MM/DD/YYYY')) + (originationtime/(86400000.0)) - (5.0/24.0)), ((TO_DATE('01/01/1970', 'MM/DD/YYYY')) + (expirationtime/(86400000.0)) - (5.0/24.0)) from messages
gives me the following:
originationtime expirationtime
dd/mm/yyyy hh:mm dd/mm/yyyy hh:mm
this will go on for 600,000 rows with different dates and times I need to obtain a count of the number of messages that with a expirationtime of say 06/29/2011 then do the same for messages with an expirationtime for 09/15/2007. Thanks...
SQL script:
select originationtime, expirationtime, ((TO_DATE('01/01/1970', 'MM/DD/YYYY')) + (originationtime/(86400000.0)) - (5.0/24.0)), ((TO_DATE('01/01/1970', 'MM/DD/YYYY')) + (expirationtime/(86400000.0)) - (5.0/24.0)) from messages
gives me the following:
originationtime expirationtime
dd/mm/yyyy hh:mm dd/mm/yyyy hh:mm
this will go on for 600,000 rows with different dates and times I need to obtain a count of the number of messages that with a expirationtime of say 06/29/2011 then do the same for messages with an expirationtime for 09/15/2007. Thanks...
Milton C. Craighead, Jr.
•
•
Join Date: Nov 2007
Posts: 51
Reputation:
Solved Threads: 9
Don't you just need to group on expirationtime?
Something like
select expirationtime, count(expirationtime)
from messages
group by expirationtime;
This will give you a list of the distinct expirationtime and the amount of times they occur.
Of course you'd have to replace the expirationtime in the above statement with your calculation of how it's derived from the database.
Nige
Something like
select expirationtime, count(expirationtime)
from messages
group by expirationtime;
This will give you a list of the distinct expirationtime and the amount of times they occur.
Of course you'd have to replace the expirationtime in the above statement with your calculation of how it's derived from the database.
Nige
![]() |
Similar Threads
- How to create script of a user/role (Oracle)
- Just for fun Lotto SQL (MS SQL)
- Connecting to a SQL Server Database using VB (VB.NET)
- what to do with this .SQL script? (MySQL)
- Importing SQL Script File - Urgent !! (Database Design)
Other Threads in the Oracle Forum
- Previous Thread: Compare subparts of a field over multiple rows
- Next Thread: Passing XML file to SP
| Thread Tools | Search this Thread |
2009predictions acquisition amazon.com bartz bernanke cia citrix cloudcomputing crm database dell economy editor enterprise enterprise2.0 enterprisesoftware federalreserve forbes hp ibm intellipedia internet larryellison layoffs linux loughridge mediawiki michaeljackson microsoft neverland nortel notebooks oil operatingsystem oracle palm rimm saas salesforce sap seagate socialcomputing sql sun sybase technologystocks virtualiron virtualization vmware wiki wikipedia xen yahoo zoho





