Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql Syntax to make this group by ?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00755254
Message ID:
00755446
Views:
8
Hi Sergey thank's a lot for you answer but if i have 2 note with the same date
i would like to get only one per client in my result

Have a Idea ?
Rock


>There are a few ways to do that.
-- #1
>SELECT * FROM mytable mt1
>  WHERE NOT EXISTS (
>     SELECT * FROM mytable mt2
>          WHERE mt2.ClientId = mt1.ClientId And mt2.date > mt1.date)
>-- #2
>SELECT * FROM mytable mt1
>  WHERE date IN (
>     SELECT MAX(date) FROM mytable mt2
>          WHERE mt2.ClientId = mt1.ClientId)
>
>>Hi everybody,
>>
>>I Have a Note table look like that
>
>
>>UniqueId  ClientId  Note                 Date
>>1         1         Comments Bla Bla     2003-01-15
>>2         1         xxx yyyy sfdfd       2003-02-01
>>3         1         yyrtr bghggggg       2003-01-19
>>4         2         zzzz zzzz kdfjd      2001-01-15
>>5         2         zzrrrrrr rrrrr       2003-01-01
>>
>>I would like to have only one note per Client but the one who have the greatiest Date.
>>
>>Exemple of the result i want.
>>
>>UniqueId  ClientId   Note                Date
>>2         1         xxx yyyy sfdfd       2003-02-01
>>5         2         zzrrrrrr rrrrr       2003-01-01
>
>
>>I try a lot of thing but noting work fine
>>Do you have an idea of the Syntaxe i need to do the jod...
>>Thank's in Advance
>>Rock
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform