English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

My Query is

In my table there is a field name
date and i want to sort on this field & want date from first & last record not in between, using single SQL Query

Plz help its urgent.

2006-09-18 04:34:07 · 4 answers · asked by priyanka.batra 1 in Computers & Internet Programming & Design

4 answers

SELECT *
FROM TABLENAME
WHERE DATECOLUMN between '2003-04-09'
AND '2003-04-10'
ORDER BY DATECOLUMN

2006-09-18 05:11:14 · answer #1 · answered by Anonymous · 0 0

What you would like to do is create an answer by using SQL.
A better and more efficient answer would be to do the select that you have described and then use program code to do some action with the first and the last item.

2006-09-18 19:13:22 · answer #2 · answered by AnalProgrammer 7 · 0 0

can you pls explain more on your requirements?

you want to sort by name, suppose there are five names - but first one is ALI and last one is ZAFAR.

do you want dates for these records only?

2006-09-18 11:53:19 · answer #3 · answered by SRee 1 · 0 0

select * from MyTable where MyDate
in
((select max(MyDate) from MyTable) union
(select min(MyDate) from MyTable))

Any records that are on the Maximum date, and any records that are on the Minimum date will be returned.

2006-09-19 22:15:13 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers