Reputation: 496
I’ve trying to list out a table with numbers that exist more than three time. As you can see, I am new to SQL. I am a bit unsure about the syntaxes and possibilities with SQL.
I have tried this:
SELECT tabel1.nr, count(tabel2.opp)
FROM tabel1
JOIN tabel2 on tabel2.opp = tabel1.opp
WHERE tabel2.opp > 3
ORDER BY tabel2.opp
This is the idea I’ve trying to figure out:
SELECT COUNT(tabel1.key = tabel2.key) as numbers
FROM table1
ORDER BY numbers > 3
Upvotes: 1
Views: 73
Reputation: 27467
try this
SELECT tabel1.nr, count(tabel2.opp)
FROM tabel1
JOIN tabel2 on tabel2.opp = tabel1.opp
GROUP BY tabel1.nr
HAVING count(tabel2.opp) > 3
ORDER BY tabel2.opp
Upvotes: 3