Oryza Sativae
Oryza Sativae

Reputation: 99

count different value in sql

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 the result of query above

and in my table, there are 5 different "sesi_ujian" values, such as : data

can you tell me how to display the counting result of "sesi_ujian" ?

Upvotes: 0

Views: 403

Answers (2)

Afiz
Afiz

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

reza
reza

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

Related Questions