Selecting highest number from a column in db then displaying

Hi boards,

I wonder if you could help me please, I'm trying to select the greatest value from an MSDE database's column and make it equal to a label.Text value. The SQL query

"SELECT [GuestbookEntries].[GuestBookEntriesID] FROM [GuestbookEntries"

will return all the values, where I just want the highest please.

Comments

  • : Hi boards,
    :
    : I wonder if you could help me please, I'm trying to select the greatest value from an MSDE database's column and make it equal to a label.Text value. The SQL query
    :
    : "SELECT [GuestbookEntries].[GuestBookEntriesID] FROM [GuestbookEntries"
    :
    : will return all the values, where I just want the highest please.
    :

    [code]
    "SELECT MAX([GuestbookEntries].[GuestBookEntriesID]) FROM [GuestbookEntries"
    [/code]

  • : [code]
    : "SELECT MAX([GuestbookEntries].[GuestBookEntriesID]) FROM [GuestbookEntries"
    : [/code]

    Thanks that's great, what about if I wanted to select the top 3 entries? :-s thanks!!
  • :
    : : [code]
    : : "SELECT MAX([GuestbookEntries].[GuestBookEntriesID]) FROM [GuestbookEntries"
    : : [/code]
    :
    : Thanks that's great, what about if I wanted to select the top 3 entries? :-s thanks!!
    :

    This should work ...

    [code]
    SELECT TOP 3 [GuestbookEntries].[GuestBookEntriesID] FROM GuestbookEntries
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories