-
Jul 26th, 2020, 11:01 AM
#1
Thread Starter
Addicted Member
[RESOLVED] ASP, ADO with SQL String Selection
Hi there,
I'm struggling to select all "cOperationId" from the Table and get their combined sum by name and sum.
I know how to query 1 by 1, but is there any solution to get all and list them?
Code:
Dim Sql, stDevId
stDevId = "NPRCS-003"
Sql = "SELECT COALESCE(SUM(cQuantity), 0) AS total FROM AppBlackBoxData WHERE cDeviceId='" & stDevId & "' AND cDate=CURDATE()"
Set Rs = Db.Execute(Sql)
Response.Write(Rs.Fields("total").Value)
The database table looks like this:
I would like to have output like this for example:
Code:
SW0001 = 1
SW0002 = 2
SW0003 = 3
PK0004 = 7
Any help would be appriciated,
Kind regards,
Viktor
-
Jul 26th, 2020, 05:58 PM
#2
Re: ASP, ADO with SQL String Selection
I'm not sure if I've interpreted your question properly, but I think this is what you are after:
Code:
SELECT cOperationId, SUM(cQuantity)
FROM AppBlackBoxData
WHERE ...
GROUP BY cOperationId
-
Jul 26th, 2020, 06:05 PM
#3
Thread Starter
Addicted Member
Re: ASP, ADO with SQL String Selection
Originally Posted by si_the_geek
I'm not sure if I've interpreted your question properly, but I think this is what you are after:
Code:
SELECT cOperationId, SUM(cQuantity)
FROM AppBlackBoxData
WHERE ...
GROUP BY cOperationId
That's it!!! +1
Thank you sooo much!
Tags for this Thread
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
|