sql query to count two type in single cloumn -


buses ---------------- |bus_no     |bus_name |type |avail_seat 

i have calculate how many ac , non ac buses there?

my query count is:

count(*)bus_count sum(case when type='ac' 1 else 0) sum (case when type="non ac" 1 else 0) buses group bus_number; 

assuming there 2 values in 'type' column, following query work:

select type,  count (*) bus_count bus group 1;  


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -