sql - Closest Date in Oracle -


I am trying to get the closest date for the date given in Oracle. I am working, but the example of that question uses two different tables. I am not a PL SQL guru and I am struggling to work on it. I have a table with ID field and a date field. I need to pass the ID that date in the nearest query.

 Select  from SEQ_ID, ENTERED_DATE, rank () (by splitting difference from the ENTERED_DATE command) as the rnk (seq_id, ENTERED_DATE, stomach (ENTERED_DATE selection - DOWNTIME_DETAILS From 1999/02/09))) as the difference where rnk = 1  

it gives me an error: "SQL command did not end properly"

< P> How do I fix a query? What am I doing wrong?

as a difference assign a table Is doing aka. You can not use like for other names in the table, only for column nickname (hence as rnk is OK). Remove just another as . As you are referring to the difference in the external question, it seems that you had a column nickname and only in the wrong place:

  Select * from SEQ_ID, ENTERED_DATE, (from the order with difference) to rank (SEQ_ID, ENTERED_DATE, stomach (ENTERED_DATE) as select - TO_DATE ('1999/02/09', 'MM / DD / YYYY ')) as the difference from DOWNTIME_DETAILS) where rnk = 1  

You also had a date without any quotation marks, so that in this case the number of forms Explained in Is, and is not the effect you wanted. You should always use clear conversions; I have guessed my date format and you should not divide by the original entered_date because it will rank everything 1. If you have two records that keep the same difference then they will still rank both so that you will see both. You can do this by modifying the order by rnk , such as

  rank () You can add it to break>  

... but you will need to specify the criteria so that it can be understood for your data and position.

You can also do this:

 Select  to select max (SEQ_ID) before the dense_rank order (ENTERED_DATE - TO_DATE ('1999/02/09) ',' MM / DD / YYYY '))) in the form of seq_id, keeping the maximum (ENTERED_DATE) (dense_rank earlier orders from stomach (Entredi_date - to_date (' 2/9/1999 ',' MM / DD / Y YYY '))) has been entered as DOWNTIME_DETAILS;  

... but then you have to provide the date twice.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -