Need help with PLSQL query [message #307709] |
Wed, 19 March 2008 11:08  |
sumit381
Messages: 2 Registered: March 2008
|
Junior Member |
|
|
Hello, I am using Oracle 10g and I am having trouble with a query.
I have the following table called Data_Table:
Columns:
URI, CurrentStat, PastStat, Date_ID
The data in my table gets loaded with different Date_IDs representing the data loaded for that year(ex. DateID = 2 for year 2008, DateID = 1 for 2007, etc.). What I want to do in my query is return all rows where CurrentStat of last year's Date_ID does NOT equal PastStat of this year's Date_ID. This will be done by checking the URI for each record and making sure it matches when comparing records from different years.
Sample Data:
URI, CurrentStat, PastStat, Date_ID
123, 001, 002, 2
123, 003, 004, 1
123, 002, 004, 1
234, 003, 006, 2
234, 006, 072, 1
So if the query is run my output from the sample data should be:
URI, PastStat(current year), CurrentStat(past year)
123, 002, 003
Any help would be greatly appreciated.
|
|
|
|
|