I have a table in my database
+------+------+----------+ | id | dept | location | +------+------+----------+ | 1 | eee | chennai | | 2 | ece | chennai | | 3 | eee | chennai | | 4 | ece | chennai | | 5 | eee | cbe | | 6 | ece | trichy | | 7 | mech | madurai | +------+------+----------+
I need the count of id on transposing one of the column. Can anyone suggest me the query to get the result below
+---------+------+-----+------+ | location| eee | ece | mech | +---------+------+-----+------+ | chennai | 2 | 2 | 0 | | cbe | 1 | 0 | 0 | | trichy | 0 | 1 | 0 | | madurai | 0 | 0 | 1 | +---------+------+-----+------+
Thank you for any help