Sunday, February 26, 2012

getting highest primary key value

Hi I have a table like
*******************
*pri key * varchar (20)*
********************
* 1 * tom *
* 2 * joe *
* 3 * paul *
Need a query that gets the highest pri key value. thanks.
mabye something like
SELECT field1
FROM table
WHERE field1 IS MAX
Paul G
Software engineer.meant to put this in the sqlserver group
"Paul" wrote:

> Hi I have a table like
> *******************
> *pri key * varchar (20)*
> ********************
> * 1 * tom *
> * 2 * joe *
> * 3 * paul *
> Need a query that gets the highest pri key value. thanks.
> mabye something like
> SELECT field1
> FROM table
> WHERE field1 IS MAX
> Paul G
> Software engineer.|||Paul
Try this
SELECT field2, MAX(field1)
FROM table
GROUP BY field2
Paul G
"Paul" <Paul@.discussions.microsoft.com> wrote in message
news:A2B750B6-990D-4B56-B0CE-301F81FF384C@.microsoft.com...[vbcol=seagreen]
> meant to put this in the sqlserver group
> "Paul" wrote:
>|||ok thanks this seemed to work.
"Uri Dimant" wrote:

> Paul
> Try this
> SELECT field2, MAX(field1)
> FROM table
> GROUP BY field2
> Paul G
> "Paul" <Paul@.discussions.microsoft.com> wrote in message
> news:A2B750B6-990D-4B56-B0CE-301F81FF384C@.microsoft.com...
>
>

No comments:

Post a Comment