Ver originalSELECT *,CASE WHEN royalty>proomedio THEN 'bla' ELSE 'bla' END AS condicion FROM(SELECT title 'NOMBRE', TYPE, royalty, avg(royalty) AS promedioFROM titlesGROUP BY royalty,title,TYPE) AS t1