Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

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?


Report this thread to moderator Post Follow-up to this message
Old Post
imani_technology_spam@yahoo.com
09-22-05 01:23 AM


Re: min(date) + 1
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.


< imani_technology_spa
m@yahoo.com> wrote in message
news:1127338921.903049.218810@z14g2000cwz.googlegroups.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?
>



Report this thread to moderator Post Follow-up to this message
Old Post
Danny
09-22-05 01:23 AM


Re: min(date) + 1
select top 1 a.date from
(select top 2 date from table order by date ) a
order by a.date desc


Report this thread to moderator Post Follow-up to this message
Old Post
masri999@gmail.com
09-22-05 12:23 PM


Re: min(date) + 1
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)

Report this thread to moderator Post Follow-up to this message
Old Post
Hugo Kornelis
09-23-05 01:24 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 01:10 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006