Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql select row with max value group by

SELECT t1.*
FROM employees t1
INNER JOIN (
    SELECT id, max(salary) AS salary FROM employees GROUP BY id
) t2 ON t1.id = t2.id AND t1.salary = t2.salary;
Comment

mysql group select max value of group by

SELECT o.*
FROM `Persons` o                    # 'o' from 'oldest person in group'
  LEFT JOIN `Persons` b             # 'b' from 'bigger age'
      ON o.Group = b.Group AND o.Age < b.Age
WHERE b.Age is NULL                 # bigger age not found
Comment

mysql group select max value of group by

SELECT t1.*
FROM yourTable t1
INNER JOIN
(
    SELECT `Group`, MAX(Age) AS max_age
    FROM yourTable
    GROUP BY `Group`
) t2
    ON t1.`Group` = t2.`Group` AND t1.Age = t2.max_age;
Comment

PREVIOUS NEXT
Code Example
Sql :: best sql collation 
Sql :: sqrt(i) 
Sql :: oracle get foreign keys on table 
Sql :: Create the connection pool mysql2 
Sql :: not between mysql 
Sql :: oracle undo tablespace schema 
Sql :: close external port 3306 with iptables 
Sql :: how to relationship query two different tables in MySQL 
Sql :: import database mysql command line 
Sql :: sql default constraint 
Sql :: SQL Server run query on linked server 
Sql :: json to dynamic columns in sql 
Sql :: dump multiple tables mysql 
Sql :: sql limit to 5 results 
Sql :: count sql 
Sql :: sqlalchemy case insensitive like 
Sql :: stored procedure sql 
Sql :: insert multiple rows from another table sql 
Sql :: TRIGGER AFTER 
Sql :: How To Rename Table Using MySQL RENAME TABLE Statement 
Sql :: intersect sql 
Sql :: subquery in mysql 
Sql :: order of execution in sql 
Sql :: how to show current database in mysql 
Sql :: oracle create index if not exists 
Sql :: microsoft sql server management studio uppercase shortcut 
Sql :: mysql join column order By and group By 
Sql :: sql select inside select sub query 
Sql :: sql query print strings and int 
Sql :: Triggers Syntax 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =