Reputation: 99
I try to count a data with integer datatype in a table
I used the query below
SELECT sesi_ujian,hari_ujian,COUNT(DISTINCT sesi_ujian) AS jumlah FROM ujian_mhs
It works, but return 1 result like this
and in my table, there are 5 different "sesi_ujian" values, such as :
can you tell me how to display the counting result of "sesi_ujian" ?
Upvotes: 0
Views: 403
Reputation: 503
If you are looking for only distinct values count. Use the below query.
SELECT COUNT(DISTINCT sesi_ujian) FROM ujian_mhs
Upvotes: 0
Reputation: 1507
your SQL for it, is wrong. try following
SELECT DISTINCT sesi_ujian,hari_ujian,COUNT(id) AS jumlah FROM ujian_mhs group by sesi_ujian
Upvotes: 1