Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    51

    Lightbulb Unanswered: "Order By" doesn't work

    Hi,

    I'm trying to make a query that will show me info on some columns and also the sum of those columns. Here is an example:

    SELECT TOP 2 col1, col2, col3, col4, (col3 + col4) as total_pts
    FROM tbl1
    ORDER BY total_pts DESC

    I get this error:

    Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

    When I get rid of "total_pts" in the Order By statement (remove the statement alltogether or simply replace "total_pts" with something else), the query executes without any problems:

    SELECT TOP 2 col1, col2, col3, col4, (col3 + col4) as total_pts
    FROM tbl1
    ORDER BY col3 DESC

    I'm connecting to the Access database from an ASP page.

    Why does it choke on the dynamically created column? It's a simple order by statement - it should work. Any ideas?

    Thanks a lot.

    NB

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Try

    SELECT TOP 2 col1, col2, col3, col4, (col3 + col4) as total_pts
    FROM tbl1
    ORDER BY (col3 + col4) DESC
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Mar 2004
    Posts
    51
    Great, it works! Thanks a lot

Posting Permissions

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