How to order by the latest of two dates ?
Hi
I try to get result from a table with the highest of two dates. First date is a created_on date, second date is "updated_on". I would like to display the lines ordered by the whatever latest date between these two.
I tried this request without result.
SELECT
name "Nom",
updated_on, created_on,
greatest (updated_on, created_on) latest
FROM doclib_documents
order by latest descYou'll find below a sample data of the table.
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('readme.txt',to_timestamp('08/03/2010 15:16:56','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('12/03/2009 11:22:41','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('doc_library_readme_0.92.txt',to_timestamp('12/02/2010 13:32:30','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('12/03/2009 11:26:14','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('01_informatique.pdf',to_timestamp('10/02/2010 13:49:34','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('12/03/2009 16:29:00','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('readme.txt',to_timestamp('08/03/2010 15:16:56','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('16/02/2010 11:40:16','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('dataguardproblem.txt.txt',to_timestamp('03/03/2010 11:19:44','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('16/02/2010 11:41:03','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('f110.sql',to_timestamp('03/03/2010 10:59:08','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('10/02/2010 13:44:45','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('1.jpg',to_timestamp('08/03/2010 14:22:00','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('08/03/2010 14:17:42','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('dads.conf',to_timestamp('03/03/2010 11:19:56','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('09/02/2010 11:19:30','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('1.doc',to_timestamp('10/02/2010 13:49:46','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('09/02/2010 11:20:28','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('1.doc',to_timestamp('15/02/2010 16:08:06','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('09/02/2010 11:33:02','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('dataguardproblem.txt.txt',to_timestamp('03/03/2010 10:57:52','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('09/02/2010 11:36:15','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('access.rtf',to_timestamp('10/02/2010 13:38:25','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('09/02/2010 12:10:57','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('temp.sql',to_timestamp('12/02/2010 14:43:58','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('11/02/2010 09:59:56','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('evv_E022_doublons.txt',to_timestamp('15/02/2010 15:55:02','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('12/02/2010 15:59:45','DD/MM/RR HH24:MI:SSXFF'));
Insert into "table_export" ("Nom",UPDATED_ON,CREATED_ON) values ('evv_E022_doublons.txt',to_timestamp('15/02/2010 16:05:58','DD/MM/RR HH24:MI:SSXFF'),to_timestamp('12/02/2010 16:00:25','DD/MM/RR HH24:MI:SSXFF'));Thank you for you kind help !
Christian
Christian from France wrote:
I am sorry, for me it does not work.
Look above my query; I get for the LATEST a date before CREATED_ON.Um, no you don't! Last time I looked, 2009 came before 2010 *{;-)
Similar Messages
-
Java code to get the difference between two dates in days
Hi ppl,
I need to write a user defined function to get the difference between two date nodes, in days.Please help me out
regards,
PrashanthHi,
have a look at those two:
(How do I calculate the difference between two dates?)
http://joda-time.sourceforge.net/faq.html
Calculating the Difference Between Two Datetime Stamps
http://www.xmission.com/~goodhill/dates/deltaDates.html
Get difference in days
http://javaalmanac.com/egs/java.util/CompDates.html
Regards,
michal -
In mail how do I get the latest emails to appear at the top of the column automatically. At the moment I have to scroll up from the bottom oldest entires to find my latest mail arrivals
What device are you using?
I assume you are talking about something other than the iPad?
Is there a sort order above the date column? Clicking on this can switch between Ascending and Descending order. -
When migrating from time machine to my new hard drive, it migrates the first back-up I made several years ago. How can I migrate the latest back-up ? I need time machine to migrate the latest back-up. Should I delete the older back-ups ?
As noondaywitch says, it should use the latest backup.
Where are your backups (external HD, Time Capsule, etc.)?
It sounds like there are two separate sets, and you're not connected to the right set. -
From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?
Hi,
Use NVL or COALESCE:
NVL (col_a, col_b)
Returns col_a if col_a is not NULL; otherwise, it returns col_b.
Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
Hi ,
How to find out the latest Record in per_all_people_f and per_all_assignments_f
Requirement : Need to find out the latest record in per_all_people_f and per_all_assignments_f to update the attribute column with pre defined value . Its not possible to track only with person_id / assignment_id and effective end date
SELECT pp_id
FROM (SELECT app.person_id pp_id,
asf.*
FROM apps.per_all_people_f app,
apps.per_all_assignments_f asf
WHERE --app.person_id=123568 and
asf.person_id = app.person_id AND
app.effective_end_date = to_date('31-dec-4712') AND
asf.effective_end_date = to_date('31-dec-4712')
GROUP BY app.person_id)
HAVING COUNT(pp_id) > 1
GROUP BY pp_id
This query also returns more than 1 value for person_id .
It would be great if you put comment on this .. Thanks in advance ,
AryaI am getting more records with asf.primary_flag='Y' . If you give ur mail id , i will send the sample data
ASSIGNMENT_ID EFFECTIVE_START_DATE EFFECTIVE_END_DATE BUSINESS_GROUP_ID RECRUITER_ID GRADE_ID POSITION_ID JOB_ID ASSIGNMENT_STATUS_TYPE_ID PAYROLL_ID LOCATION_ID PERSON_REFERRED_BY_ID SUPERVISOR_ID SPECIAL_CEILING_STEP_ID PERSON_ID RECRUITMENT_ACTIVITY_ID SOURCE_ORGANIZATION_ID ORGANIZATION_ID PEOPLE_GROUP_ID SOFT_CODING_KEYFLEX_ID VACANCY_ID PAY_BASIS_ID ASSIGNMENT_SEQUENCE ASSIGNMENT_TYPE PRIMARY_FLAG APPLICATION_ID ASSIGNMENT_NUMBER CHANGE_REASON COMMENT_ID DATE_PROBATION_END DEFAULT_CODE_COMB_ID EMPLOYMENT_CATEGORY FREQUENCY INTERNAL_ADDRESS_LINE MANAGER_FLAG NORMAL_HOURS PERF_REVIEW_PERIOD PERF_REVIEW_PERIOD_FREQUENCY PERIOD_OF_SERVICE_ID PROBATION_PERIOD PROBATION_UNIT SAL_REVIEW_PERIOD SAL_REVIEW_PERIOD_FREQUENCY SET_OF_BOOKS_ID SOURCE_TYPE TIME_NORMAL_FINISH TIME_NORMAL_START BARGAINING_UNIT_CODE LABOUR_UNION_MEMBER_FLAG HOURLY_SALARIED_CODE REQUEST_ID PROGRAM_APPLICATION_ID PROGRAM_ID PROGRAM_UPDATE_DATE ASS_ATTRIBUTE_CATEGORY ASS_ATTRIBUTE1 ASS_ATTRIBUTE2 ASS_ATTRIBUTE3 ASS_ATTRIBUTE4 ASS_ATTRIBUTE5 ASS_ATTRIBUTE6 ASS_ATTRIBUTE7 ASS_ATTRIBUTE8 ASS_ATTRIBUTE9 ASS_ATTRIBUTE10 ASS_ATTRIBUTE11 ASS_ATTRIBUTE12 ASS_ATTRIBUTE13 ASS_ATTRIBUTE14 ASS_ATTRIBUTE15 ASS_ATTRIBUTE16 ASS_ATTRIBUTE17 ASS_ATTRIBUTE18 ASS_ATTRIBUTE19 ASS_ATTRIBUTE20 ASS_ATTRIBUTE21 ASS_ATTRIBUTE22 ASS_ATTRIBUTE23 ASS_ATTRIBUTE24 ASS_ATTRIBUTE25 ASS_ATTRIBUTE26 ASS_ATTRIBUTE27 ASS_ATTRIBUTE28 ASS_ATTRIBUTE29 ASS_ATTRIBUTE30 LAST_UPDATE_DATE LAST_UPDATED_BY LAST_UPDATE_LOGIN CREATED_BY CREATION_DATE TITLE OBJECT_VERSION_NUMBER
931510 7-Nov-08 31-Dec-12 122 (null) (null) (null) 3978 1 (null) 14402 (null) 220150 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 2 E Y (null) 100035417-2 (null) (null) (null) 45948739 (null) (null) (null) (null) (null) (null) (null) 868007 (null) (null) (null) (null) 449 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)
797386 26-Aug-08 26-Aug-08 122 (null) (null) (null) 3980 3 (null) 14402 (null) 218925 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 1 E Y (null) 100035417 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) 740071 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)
916076 26-Aug-08 31-Dec-12 122 (null) (null) (null) 3980 1 4 14402 (null) 218925 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 1 B Y (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)
797386 25-Feb-08 25-Aug-08 122 (null) (null) (null) 3980 1 (null) 14402 (null) 218925 (null) 734956 (null) (null) 476 (null) (null) (null) (null) 1 E Y (null) 100035417 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) 740071 (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) -
How do I install the latest version of Quicktime so that I can run iTunes?
When I try to upgrade to iTunes 8, , I get a message saying that I need the latest version of Quicktime. How do I install the latest version of Quicktime? Is it necessary to ru n iTunes?Please help!
Hello Slm7531
Check to make sure that your that you do not have anything that would be blocking access to the iTunes store like a firewall or security software. The second article below will assist with troubleshooting accessing the iTunes Store.
iTunes 11.1.2
http://support.apple.com/kb/dl1614
Can't connect to the iTunes Store
http://support.apple.com/kb/ts1368
Regards,
-Norm G. -
How to get the difference of two dates in years,months and days
Hi friends,
how to get the difference of two dates in years,months and days
for ex 2 years 3 months 13 days
select (sysdate-date_Start) from per_periods_of_service
thanksSomething like this...
SQL> ed
Wrote file afiedt.buf
1 with t as (select to_date('17-nov-2006','dd-mon-yyyy') as c_start_date, to_date('21-jan-2008','dd-mon-yyyy') as c_end_date from dual union all
2 select to_date('21-nov-2006','dd-mon-yyyy'), to_date('17-feb-2008','dd-mon-yyyy') from dual union all
3 select to_date('21-jun-2006','dd-mon-yyyy'), to_date('17-jul-2008','dd-mon-yyyy') from dual
4 )
5 -- end of test data
6 select c_start_date, c_end_date
7 ,trunc(months_between(c_end_date, c_start_date) / 12) as yrs
8 ,trunc(mod(months_between(c_end_date, c_start_date), 12)) as mnths
9 ,trunc(c_end_date - add_months(c_start_date, trunc(months_between(c_end_date, c_start_date)))) as dys
10* from t
SQL> /
C_START_D C_END_DAT YRS MNTHS DYS
17-NOV-06 21-JAN-08 1 2 4
21-NOV-06 17-FEB-08 1 2 27
21-JUN-06 17-JUL-08 2 0 26
SQL>But, don't forget that different months have different numbers of days, and leap years can effect it too. -
How can I download the latest Microsoft Office for my Macbook Air through the App Store?
How can I download the latest Microsoft Office for my Macbook Air through the App Store?
Welcome to Apple Support Communities
Microsoft Office is not available in the App Store. Instead, you can purchase it in the Microsoft site > http://www.microsoft.com/mac
Note that there are other apps that do the same, like Apple iWork (available in the Mac App Store) or LibreOffice, open-source and free. I recommend you to give LibreOffice a try.
If you are interested in Office for Windows, you can find it in the Microsoft Store or at shops -
I can't open the RAW files from my new Nikon D4s camera in photoshop? How do I download the latest software for RAW files? Cheers!
What version of Photoshop are you running? You will need at CS5, CS6, CC or CC2014. Each version needs a different ACR-plug-in to open files from that camera.
If you are on CS4 or earlier, you'll need to upgrade—or, in the alternative; look for, download, instal, launch and run the free, stand-alone DNG Converter 8.6 on each file of raw NEF files to convert them to raw DNGs first so you can open them in your version of Photoshop and ACR plug-in higher than 2.4. -
How can I download the latest version of iTunes to my iPad when I don't have enough space in my local c disc on my laptop?
You don't download itunes to your ipad at all.
-
How can I download the latest version of Safari? Exact instructions.
How do I download the latest version of Safari? I keep getting a message that my current version is no longer supported. Isn't there something I can just click on? I can't see how to actually download it (gen x, not as smart as I once was ), but please help me anyway.
You may have to settle for as recent of version of Firefox, as your OS X 10.6.8 will allow.
Even an older archived Firefox would be more recent than Safari from that era.
https://www.mozilla.org/en-US/firefox/new/
see:
https://support.mozilla.org/en-US/kb/how-download-and-install-firefox-mac
The method to get a later version of Safari, would be to see if the computer can be upgraded
to a later fully new OS X which includes a period-correct Safari version. That's about it.
And an upgrade to a later OSX may compromise the kind of computing experience you'd
found acceptable with Snow Leopard 10.6.8. I'd consider a later computer, as a vehicle to
access later OS X versions, and keep the older computer (with backups) in Snow Leopard.
The online App Store may suggest a later OS X version than you have. The latest it may
(or not) support is Yosemite. That would likely require a RAM upgrade and perhaps a new
hard disk drive of faster rotational speed, or perhaps an upgrade to SSD, to add speed to
allow the bulkier newer OS X to work OK. Then you may need to get newer applications.
Other available OS X versions, not as new as Yosemite, would be available by purchase
in the Apple Store online. A code would be sent to your email, to unlock these downloads.
If you fall into the potential upgrade trap, be sure to create viable external clone or bootable
copy of your current system on external device; and have backup Time Machine archive, too.
In any event... there isn't a newer Safari for Snow Leopard 10.6.8.
Good luck & happy computing! -
How can i compare the contents of two folders ?
how can i compare the contents of two folders and find out which files are in one but not in the other?? Knowing how to do this would be the best thing ever, especially when dealing with a large number of files. Often, for instance, I'm dealing with a large number of images, processing them, and saving the retouched ones to a new folder, and need to check that they are all there. If there are say three files missing in the second folder (out of say a hundred in total) being able to automate the process of elimination would be very useful. Please help!!!
BI really wish I knew the answer to this. I work between two macs, a G5 and MacBook Pro when I'm on the go. Each time I move from one to the other I have to copy all my files to the computer I'm going to work on, so I end up with the same files being duplicated. It's not a problem if it's not much data but in my case the it can be to 30GB, mostly graphics files, photoshop, motion, final cut pro, etc.
There's has got to be a way automator can make a comparison between two folders to sort out what's changed and what's remained the same. It would be nice also if this feature could be done globally on the hard disk using spotlight's technology to stop files being duplicated in places you didn't even know about and taking up valuable disk space. I'm not sure how this could be done.
Any bright ideas Apple? -
Installation, how do i download the latest camera raw plugin for elements 11
how do i download the latest version of camera raw plugin for elements 11
Hi sheffwedtheowls,
You can download the Camera Raw from : http://www.adobe.com/support/downloads/product.jsp?product=106&platform=Windows
Adobe application...
Shipped with Camera Raw plug-in version...
Compatible with Camera Raw plug-in through version...
Photoshop Elements 11
7.1
8.0
Please refer : http://helpx.adobe.com/x-productkb/global/camera-raw-compatible-applications.html
Regards,
Rave -
How do I get the latest camera raw for Lightroom 4.2?
How do I get the latest camera raw for Lightroom 4.2?
You simply run the updater. if there is a newer version, it will be installed. Other than that 4.2 is the latest release version, 4.3 is currently in the final testing stages and can be downloaded from the Adobe Labs pages.
Mylenium
Maybe you are looking for
-
Within a certain app, how do I set up tabs at the top of my iPad?
I have a app that we use within our Church. I want to have multiple publications opened at the same time and be able to tab from one to the other. Is this possible?
-
FDM: Maintenance cost associated to FDM.URGENT
We have bought FDM which includes the SAP-FIN-A Adapter. I am paying an anual maintenance fees so i have the following doubt: SAP-FIN-A adapter has 14 fields that are pulled from SAP Financials (always the same fields): 1. Scenario 2. Company code 3.
-
Best strategy to replace system files/folders from backup?
I'm having a problem with Mail and Safari quitting upon launch (posted in the Safari for Mac area). Things I've tried in my attempt to solve problem: -repaired permissions -cleaned cache -ran hardware test and removed suspect ram -ran disk utility an
-
I wanted 20 minutes and paid for my rentals and I can't find it anywhere. Can someone help me?
-
Como grabar las pistas en CD desde adobe audition
Hola amigos espero que puedan ayudarme, tengo un gran problema, comó grabo en cd las pistas que hago en adobe audition. Porfa ayudenme y se los agradesco.