Hi,
I have the following output in a table:
UID FID nDate
-----------------------------------
178 100 2013-06-03 16:12:23.000
178 99 2013-05-30 07:30:41.000
178 99 2013-05-30 07:26:59.000
178 99 2013-05-30 07:24:14.000
178 99 2013-05-29 06:58:13.000
178 99 2013-05-29 06:51:59.000
178 99 2013-05-28 20:02:10.000
I just want to retrieve UID, FID and Date column based on latest date entry so the result should look like this:
UID FID nDate
-----------------------------------
178 100 2013-06-03 16:12:23.000
178 99 2013-05-30 07:30:41.000
Any help would be great.
|
Re: Query Issue with Date |
|
sumikumar@gmail.com wrote:
> Hi,
>
> I have the following output in a table:
>
> UID FID nDate
> -----------------------------------
> 178 100 2013-06-03 16:12:23.000
> 178 99 2013-05-30 07:30:41.000
> 178 99 2013-05-30 07:26:59.000
> 178 99 2013-05-30 07:24:14.000
> 178 99 2013-05-29 06:58:13.000
> 178 99 2013-05-29 06:51:59.000
> 178 99 2013-05-28 20:02:10.000
>
> I just want to retrieve UID, FID and Date column based on latest date entry so the result should look like this:
>
> UID FID nDate
> -----------------------------------
> 178 100 2013-06-03 16:12:23.000
> 178 99 2013-05-30 07:30:41.000
>
> Any help would be great.
Pretty basic...
SELECT UID, FID, MAX(nDate)
FROM my_table
GROUP BY UID, FID
--
Gert-Jan
|