Search
 
SCRIPT & CODE EXAMPLE
 

SQL

postgresql must appear in the group by clause or be used in an aggregate function

Try using "DISTINCT" instead of "GROUP BY"
Comment

column must appear in the GROUP BY clause or be used in an aggregate function

SELECT m.cname, m.wmname, t.mx
FROM (
    SELECT cname, MAX(avg) AS mx
    FROM makerar
    GROUP BY cname
    ) t JOIN makerar m ON m.cname = t.cname AND t.mx = m.avg
;

 cname  | wmname |          mx           
--------+--------+------------------------
 canada | zoro   |     2.0000000000000000
 spain  | usopp  |     5.0000000000000000
Comment

PREVIOUS NEXT
Code Example
Sql :: 2nd max salary query in sql 
Sql :: to_date postgresql 
Sql :: full join sql 
Sql :: select users with same username 
Sql :: sql trim from string 
Sql :: print hello world in sql 
Sql :: exec procedure oracle 
Sql :: sql oracle limit 
Sql :: postgresql function round 
Sql :: SQL Subquery and JOIN 
Sql :: import mysql dump database command line linux 
Sql :: mssql server port 
Sql :: sql last time database was accessed 
Sql :: drop database using terminal postgres 
Sql :: truncate psql 
Sql :: sqlite select split string 
Sql :: mysql select or insert current datetime 
Sql :: add column alter table default value 
Sql :: oracle error line 
Sql :: mysqli inner join (php) 
Sql :: sql order by with where 
Sql :: on update current_timestamp jpa 
Sql :: count in sql 
Sql :: drush SQLSTATE[HY000] [2002] No such file or directory 
Sql :: connecting to postgresql on windows amd ubuntu 20.04 
Sql :: square in sql 
Sql :: sql insert into statement 
Sql :: sql server select record with max id 
Sql :: sql limit to 5 results 
Sql :: oracle job class 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =