Advanced Search

Results 1 to 2 of 2

Thread: Max function using where option

  1. #1
    Join Date
    Nov 2010
    Posts
    114
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Default Max function using where option

    Hi All,

    I am writing a query where i can get the maximum Id and its name. So iam using this option Max. But this is giving me error.


    SELECT Id,Name FROM `User` WHERE Id = Max(Id);

    When i submit this query iam getting error

    Invalid use of group function

    After this i also want query for my second largest Id i am having. Anyone help me in this issue

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    Have you tried something like MAX(colname.ID)? It might be using ID as the same as the current entry and having a "max" of a single value doesn't mean anything (or its irrelevant if so). Just a thought. I'm not sure about this.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •