search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

1 answers
Q&A SQL Count() also requires 0
SQL Count() also requires 0
P粉547362845 2024-04-06 19:48:53 Views 1256

0

I only have one table and I want to count each entry of a tag starting from 0

Now I try this:

SELECT label, COUNT(start) AS Anzahl, user_id FROM datensammlung where (start='1') AND (user_id='1') GROUP BY label;

But the reward is only:

Label quantity User ID
1_Eating Spoon 20 1
1_Blow your nose 20 1

But I want this:

Label quantity User ID
1_Eating Spoon 20 1
1_Blow your nose 20 1
1_Telephone 0 1
Your Answer
submit

1 answers
0

If all label are available in the table, you can use conditional aggregation:

SELECT label, 
       SUM(user_id = '1' AND start = '1') AS Anzahl 
FROM datensammlung 
GROUP BY label;
2024-04-07 12:09:57

submit

Popular tool

vc9-vc14 (32+64 bit) runtime library collection (link below)

vc9-vc14 (32+64 bit) runtime library collection (link below)

Download the collection of runtime libraries required for phpStudy installation

VC9 32-bit

VC9 32-bit

VC9 32-bit phpstudy integrated installation environment runtime library

PHP programmer toolbox full version

PHP programmer toolbox full version

Programmer Toolbox v1.0 PHP Integrated Environment

VC11 32-bit

VC11 32-bit

VC11 32-bit phpstudy integrated installation environment runtime library

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use