Skip to content
Advertisement

Number of similar columns occurrences

I am new to SQL SERVER and need your advise on something. I have a big table with stores information. Here is bench_id column:

I have created another small table with two columns:

The second table’s NUMBER column is showing the number of bench_id’s occurrences. I have tried this code:

But can not get the right answer I am expecting with number of bench_id occurrences. Can you point out what I am doing wrong?

Advertisement

Answer

You need to have GROUP BY clause since you need to use COUNT() to count the occurence of benchID.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement