473,320 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

latest date problem

have one table with columns: ID and submission_date
now I have to select ID from this table where submission_date is latest to given date.
Jun 24 '10 #1
3 1433
debasisdas
8,127 Expert 4TB
What exactly you mean by submission_date is latest to given date ?
Jun 24 '10 #2
I will explain with example:

suppose there is
ID submission_date (yy.mm.dd)
1 2009-07-06
2 2009-03-07
3 2009-06-06
4 2010-06-06
5 2009-07-06

now if I say SELECT submission_date latest to '2009-06-06' then I want only ID 1 and 5 which is latest(close) to given date( bcz ID 1 and 5 have same submission_date)
____________________________________
Jun 24 '10 #3
OraMaster
135 100+
@pushaskhelp
Try it out

Expand|Select|Wrap|Line Numbers
  1. SELECT ID,submission_date
  2.   FROM <table name>
  3.  WHERE submission_date =
  4.           (SELECT submission_date
  5.              FROM (SELECT DISTINCT submission_date,
  6.                                    DENSE_RANK () OVER (ORDER BY submission_date) seq_num
  7.                               FROM <table name>
  8.                              WHERE submission_date >
  9.                                           TO_DATE ('<input date>', 'YYYY-MM-DD'))
  10.             WHERE seq_num = 1)
Jun 28 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dominique Javet | last post by:
Hello, I'm new to php and mysql and I use Dreamweaver MX 2004, so sorry for this "newbie" question... I've found no answer in the forum ... I've a date problem with my formular. In my mysql DB...
3
by: jas | last post by:
> This is what I want to do with the data table below. > > I only want it to show one id for each issue. ( ie, 4001 only once, > 4002 only once, etc. But only the one with the latest date and...
2
by: John | last post by:
I have a query that returns this recordset: Bob, 1/1/2000 Bob, 3/1/2001 Bob, 2/4/2004 Bob, 5/9/2002 I need the query to return this instead: Bob, 2/4/2004 So, it needs to return the most...
1
by: TGEAR | last post by:
I have a column which stores dates (datetime data type). I would like to fetch one data which is the most latest date among them. So if there are 04/01/06, 05/08/06, 05/12/06, 06/15/06, then...
0
by: TGEAR | last post by:
I have an ItemSTDPriceHistory table as below and this is a child table of itemlookup table with one to many relationship. if exists (select * from dbo.sysobjects where id = object_id(N'.') and...
1
by: crimanysakes | last post by:
Someone should write a FAQ on how to grab various "latest dates" from MySQL; cuz I'm quite confused. Not sure how much to include; but here' my query to get my first "subset" of data: select...
6
by: piyushdabomb | last post by:
Hi All, Currently, I have a SQL query where I need to grab the SECOND latest date by group. COMPONENTID COMPLETIONDATE CBT_HAZCOM 02/26/2007 15:17:00 CBT_HAZCOM 07/31/2007 21:23:00 QS ...
8
by: helpmeplease213 | last post by:
Hello, I have a table that has five categories: Unit No, Date, P1, P2, P3. I have a query that only extracts data from the table that is over 40 for P1, P2 or P3 but I only want the data with...
2
by: selvialagar | last post by:
i have a date field in a table..i want to retrieve the data with latest date...is there any query for that.....
1
by: SunshineInTheRain | last post by:
I have a log table. I want to get record of latest date. Meaning if 1-May-2008 13:32:22 and 1-May-2008 2:22:21, it will retrieve 1-May-2008 13:32:22 as a result. how the statement should be? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.