Results 1 to 6 of 6

Thread: Counting Records Question

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    63

    Question Counting Records Question

    This is an intersting question I can't figure out.

    I have a database that has data in the following format:

    ====================
    LOCATION QTY
    FORT MYERS 10
    NAPLES 12
    NASHVILLE 18
    FORT MYERS 15
    NASHVILLE 12
    NAPLES 22
    ====================

    What I want to do is, on an asp page, have it say:

    ====================
    LOCATION QTY
    FORT MYERS 25
    NAPLES 34
    NASHVILLE 30
    ====================

    Any solutions/ideas are better than no solutions/ideas

    All help apreciated

    Kind Regards,
    Hakan

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    I believe the correct SQL syntax is like:

    SELECT Location, SUM(QTY) FROM ...
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    63
    Here is how I adopted your code to work in my page:
    ===================================================================
    SELECT LOCATION, SUM(QTY) FROM MAIN WHERE LOCATION = 'FTM'
    ===================================================================

    When I tried your code, here is what I got as a error message:
    ===================================================================
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [Microsoft][ODBC Microsoft Access Driver] You tried to execute a query that does not include the specified expression 'QTY' as part of an aggregate function.
    ===================================================================

    Any suggestions,
    Hakan

  4. #4
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    SELECT Location, SUM(QTY) AS SUMQTY FROM Main
    GROUP BY Location;
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    63
    You are awesome man... I have never come across using the sum command in sql statement. You recommend any books or www sites I can check out to do some homework on code applications like the one you just showed me...

    Greatly Apreciated,
    Hakan

  6. #6
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

Posting Permissions

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



Click Here to Expand Forum to Full Width