Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql get max value and id

SELECT a.id, a.rev, a.contents
FROM YourTable a
INNER JOIN (
    SELECT id, MAX(rev) rev
    FROM YourTable
    GROUP BY id
) b ON a.id = b.id AND a.rev = b.rev
Comment

mysql find max value row

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

PREVIOUS NEXT
Code Example
Sql :: Sequelize model datatype of enum 
Sql :: best sql collation 
Sql :: decimal() mysql 
Sql :: psql show db 
Sql :: mariadb case switch 
Sql :: dublicate row sql 
Sql :: sql composite key 
Sql :: soql update query 
Sql :: sqlite modify row 
Sql :: t-sql add column 
Sql :: mysql size of database 
Sql :: Create table with JSON column SQL Server 
Sql :: SELECT everything from a sql table 
Sql :: postgres select except 
Sql :: postgres full text search example 
Sql :: mysql query to select the highest value 
Sql :: sql drop all tables 
Sql :: mysql query where in select 
Sql :: oracle cpu metric 
Sql :: sql get actual fiscal year 
Sql :: round .5 to 1 in sql server 
Sql :: python sqlalchemy orm to select null values 
Sql :: how to get second highest salary in each department in sql 
Sql :: List all the items that have not been part of any purchase order. sql 
Sql :: SQL Greater than () 
Sql :: how to verify sequence result in oracle SQL 
Sql :: how to completely uninstall sql server 
Sql :: foreign key in sql dbms 
Sql :: psql invalid command N 
Sql :: insert into table sql 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =