1 Attachment(s)
[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:
Attachment 178077
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
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
Re: ASP, ADO with SQL String Selection
Quote:
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! ;)