close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Is my query out of scope for query builder?

Thread began 4/18/2020 11:05 am by Paul | Last modified 4/20/2020 1:40 pm by Ray Borduin | 20 views | 1 replies |

PaulBeta Tester

Is my query out of scope for query builder?

I think the query builder is a really useful tool, however I may have a requirement which I don't seem to be able to resolve in QB.

Simplified; I have a table;

Make---------------STP
A. ---------------1
A ---------------1
A ---------------0
B ---------------0
B ---------------0
B ---------------1
C ---------------1
C ---------------1
C ---------------1
C ---------------0


I need a query which outputs a count of distinct values for A and against each, count (or sum) only where STP = '1'

The resultant table would look thus;

Make STP
A. (3) (2)
B. (2). (1)
C. (4). (3)

I've compiled the following in QB however the output is duplicating the same totals for each column; Make & STP.

SELECT Sum(DEVICE_STP) AS SumDEVICE_STP, Count(DEVICE_Make) AS CountDEVICE_Make
FROM TACdb2
WHERE DEVICE_STP = 1
GROUP BY DEVICE_Make
ORDER BY DEVICE_STP DESC

Grateful for a nudge in a direction that corrects the above.


Resolved:

For my solution, I researched and hand wrote the sql.
On this occasion QB didn't have the scope to assist unfortunately.

Sign in to reply to this post

Ray BorduinWebAssist

SELECT DEVICE_Make, Count(DEVICE_Make) AS CountDEVICE_Make, Sum(DEVICE_STP) AS SumDEVICE_STP
FROM TACdb2
GROUP BY DEVICE_Make
ORDER BY DEVICE_Make ASC

Sign in to reply to this post
Did this help? Tips are appreciated...

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...