?
Solved

SQL Statement

Posted on 2007-08-10
7
Medium Priority
?
220 Views
Last Modified: 2013-12-19
I have an Oracle 8.something I need to query based on date year in TOAD
How would I change the sql statement below to Oracle SQL to get the data from March of 2007?

select * from dbo.table1
where year(ord_dt)='2007' and Month(ord_dt) = 3
0
Comment
Question by:lrbrister
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 19670805
try this

select * from dbo.table1
where ord_dt >='2007-03-01'
0
 
LVL 20

Expert Comment

by:gatorvip
ID: 19670852
select * from dbo.table1
where ord_dt >= to_date('03-01-2007', 'MM-DD-YYYY')
    and ord_dt <  to_date('04-01-2007', 'MM-DD-YYYY')
0
 

Author Comment

by:lrbrister
ID: 19670869
hongjun:
  I need to be a little clearer.  
This is a prerequisite to building a case statement so that I can build a query where each column is a prticular month's sales etc.

I really need that month / year ability without using a lot of >+ and <+ whis is what would have to be done.
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 20

Accepted Solution

by:
gatorvip earned 2000 total points
ID: 19670922
select * from dbo.table1
where  extract(YEAR FROM ord_dt) = 2007
    and extract(MONTH FROM ord_dt) = 3
0
 
LVL 33

Expert Comment

by:hongjun
ID: 19670933
try this

select * from dbo.table1
where (year(ord_dt) = 2007 and month(ord_dt) >= 3) or (year(ord_dt) > 2007)
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 19670958
select ...
from table
where to_char(ord_dt,'RRRR')='2007' and to_char(ord_dt,'fmMM') = 3;
0
 

Author Comment

by:lrbrister
ID: 19670971
gatorvip:

perfect.  Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Via a live example, show how to take different types of Oracle backups using RMAN.

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question