Using the distinct function in SQL

前端 未结 18 948
無奈伤痛
無奈伤痛 2021-02-06 16:55

I have a SQL query I am running. What I was wanting to know is that is there a way of selecting the rows in a table where the value in on one of those columns is distinct? When

18条回答
  •  北恋
    北恋 (楼主)
    2021-02-06 17:52

    The following might help you get to your solution. The other poster did point to this but his syntax for group by was incorrect.

    Get all teachers that teach any classes.

       Select teacher_id, count(*)
        from teacher_table inner join classes_table
        on teacher_table.teacher_id = classes_table.teacher_id
        group by teacher_id
    

提交回复
热议问题