webrider
webrider

Reputation: 95

counting type of data in a row

I have a table, named "stu_id" which contain 3 fields, like "sem_id", "crs_id", "session" with some of data.

"sem_id"(cse1/1, cse1/1, cse1/1, cse1/1, cse1/1) "crs_id"(cse101, cse102, cse103, cse104, cse105) "session"(spring2009, spring2009, spring2010, spring2009, spring2010)

![stu_id][table]

Now, i want to count how much type of session is there in session field (Of course here the answer will be two types). Its not like the number of "spring2009" and "spring2010" data in that field. Simply want to count the "type of session". So, what will be the mysql query for this.- Thank you.

Upvotes: 0

Views: 37

Answers (1)

Viral Jain
Viral Jain

Reputation: 1014

SELECT count(sess) from (SELECT distinct(session) as sess FROM stu_id);

If that's what u want... :)

Upvotes: 1

Related Questions