sql - Getting a "not a single-group group function" error, tried researching it -


i'm taking database summer course i'm new @ this. here code. i'm trying display average price each type of book in database.

select distinct type, avg(price) average_price  book  order type; 

the error because trying select data (type) in grouped query. avg function causes query grouped, whole result single group haven't specified group by.

to average each type of book, need group on type:

select type, avg(price) average_price book group type order type; 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -