473,402 Members | 2,055 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,402 software developers and data experts.

min(date) + 1

I know you can use the min function to get the first date within a
recordset. However, is there a way to get the second date in a
recordset? In other words, is there a way to get "min(date) + 1" or a
"next-to-earliest date" essentially?

Sep 21 '05 #1
3 12628
Try somehthing like...

select min(a.date) from (select date from table b where b.date > (select
min(c.date) from table c)) a

This should get the next earliest date not necessarily the next min date if
there are duplicate min dates.
<im*******************@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I know you can use the min function to get the first date within a
recordset. However, is there a way to get the second date in a
recordset? In other words, is there a way to get "min(date) + 1" or a
"next-to-earliest date" essentially?

Sep 21 '05 #2

select top 1 a.date from
(select top 2 date from table order by date ) a
order by a.date desc

Sep 22 '05 #3
On Wed, 21 Sep 2005 23:21:52 GMT, Danny wrote:
Try somehthing like...

select min(a.date) from (select date from table b where b.date > (select
min(c.date) from table c)) a

This should get the next earliest date not necessarily the next min date if
there are duplicate min dates.


Hi Danny,

No need to use a derived table, though. This'll work as well:

SELECT MIN(a.date)
FROM table AS a
WHERE a.date > (SELECT MIN(b.date) FROM b.table))

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Sep 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: DCM Fan | last post by:
{CREATE TABLEs and INSERTs follow...} Gents, I have a main table that is in ONE-MANY with many other tables. For example, if the main table is named A, there are these realtionships: A-->B...
7
by: Sunny K | last post by:
Hi guys, whilst working on a project which I thought was nearly complete I have come across a problem which was some how over seen, which I am hoping one of you guys know how to resovle. ...
3
by: Ker | last post by:
I have a query that works great. It gives me the min for multiple fields. Within this query, I also need to get the max of some fields too. I currently have output of Date Name ...
0
by: Scott Morford | last post by:
This is a followup to a question I posed last summer. http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=utf-8&selm=3f451dd4%240%241095%247f8943f3%40newsreader.visi.com I'm developing a weed...
2
by: Avanti | last post by:
I have a date property in the class and I wanted to assign it a min date. Public class test Public Property CreatedBy() As String Get Return mCreatedBy
15
by: edouard.spooner | last post by:
Hi, I have a tricky SQL query problem that I'm having probs with. I have a table which resembles something like this Date | Price1 | Price2 | Price3 01 Jan 2006 | 100 | 100 | 100 02 Jan...
4
by: nathanh | last post by:
Hey all, I am looking for some help on min,max, avg, here is my code that I am using to get the min, max, avg. It is for a report that I need to submit once a year and I am looking to have it for...
5
by: Artie | last post by:
Hi, I have a date field stored as an INT and need to convert to a date format mm/dd/yyyy. I'm having trouble determining what the starting date is. min(date) = 730395 max(date) = 733189 ...
4
by: ahmurad | last post by:
Dear Brothers, I am struggling the following four Date-Time type values which were inputted into MYSQL database in different tables. As MYSQL Default Time Format: YYYY-MM-DD HH:MM:SS, So I used...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.