Home > Archive > MS SQL Server security > May 2005 > getting highest primary key value









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author getting highest primary key value
Paul

2005-05-02, 8:23 pm

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

2005-05-02, 8:23 pm

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.

Uri Dimant

2005-05-03, 7:23 am

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@microso
ft.com...[color=darkred]
> meant to put this in the sqlserver group
>
> "Paul" wrote:
>


Paul

2005-05-03, 8:23 pm

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@microso
ft.com...
>
>
>

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com