|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi..All.
I can't get distinct row from query..i tried a lot but couldnt succeded. Let me explain in brief. I am having a table name usermaster. Having column..RID(autogen), Name, Date, Miniute. Now when i tried to fetch rows between two dates, at that time it gives all rows between those dates..What i want is uniq name with max date...for example There are two rows... id, name, date, min 1, Dev, 10/26/04, 20 2, Dev, 10/27/04, 30... now i want the last rows to be fetched as its max date...when I tried query with date between 10/26/04 to 10/28/04..both row comes.. I used distinct, groupby, order by ...but it wont work... Pls. pls. help me to sort it out.. Thanx. Dev ![]() |
|
#2
|
||||
|
||||
|
Try this
Code:
SELECT DISTINCT Name, Max(sDate) FROM Table1 WHERE sDate BETWEEN '10/26/2004' AND '10/28/2004' GROUP BY Name |
|
#3
|
|||
|
|||
|
Thanx Memnoch..
It really worked, but the problem is "i want all fileds in query". When i tried all field in select statement. It gives order by error. So i added those fileds in order by clause too..so same thing happend...I got both row in return..!! Please guide me to get all fields of table....??? |
|
#4
|
|||
|
|||
|
Hureey....
ThanX..memnoch. It worked..I changed the postion of field in select statement...and GOTCHA..what i want.. THANKS..A..LOT. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Want distinct row in query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|