mysql - How to return Multiple outputs from a database as different columns in SQL -


i trying access outputs database.

question : how many songs released during each decade classification of pop music. how can output songs in different decades in 1 single query search.

the desired output should different columns songs different decades.

my try first 2 decades.

 select count(*) before1970 songs , classification = 'pop'   releaseyear < 1970 ,   (select count(*) 'before1980' songs   releaseyear between 1970 , 1980 , classification = 'pop' ); 

i checked oldest song database 1969 used 1970 starter , go each decade, output returns nothing.

another alternative:

select  sum(if(releaseyear < 1970, 1, 0)) before1970,  sum(if(releaseyear >= 1970 , releaseyear <= 1980, 1, 0)) before1980  songs classification = 'pop'  

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -