Answers for "sql join with count of other table"

SQL
1

mysql select and count left join

select
  t.Topic,
  t.Title,
  count(distinct s.starID) as StarCount,
  count(distinct m.User) as UserCount,
  count(distinct m.messageID) as MessageCount
from
  Topics t
  left join Messages m ON m.Topic = t.Topic
  left join Stars_Given s ON s.Topic = t.Topic
group by
  t.Topic,
  t.Title
Posted by: Guest on April-27-2020
0

sql query for getting data with join and count

Correlated subquery

SELECT job_Desc
 ,(select count(*) from employee where employee.job_id = jobs.job_id) as count
FROM Jobs
ORDER BY 2

refrence:
https://azagappan.wordpress.com/2006/06/23/using-count-with-joins/#:~:text=COUNT(*)%20returns%20the%20number,number%20of%20unique%2C%20nonnull%20values.
Posted by: Guest on January-10-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language