|
-
May 9th, 2001, 10:05 AM
#1
Thread Starter
Member
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
-
May 9th, 2001, 11:51 AM
#2
Black Cat
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.
-
May 9th, 2001, 12:56 PM
#3
Thread Starter
Member
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
-
May 9th, 2001, 01:09 PM
#4
Black Cat
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.
-
May 9th, 2001, 01:25 PM
#5
Thread Starter
Member
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
-
May 9th, 2001, 02:14 PM
#6
Black Cat
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|