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 :: convert html to plain text in sql server 
Sql :: difference between 2 query results sql server 
Sql :: sql server version check 
Sql :: add column alter table default value 
Sql :: len sql 
Sql :: sql query inner join 3 tables 
Sql :: oracle error line 
Sql :: unique in sql server 
Sql :: python sqlite3 search 
Sql :: SQL Modify Column in a Table -SQL Server 
Sql :: postgresql create table as select 
Sql :: select mysql limit to 2 decimal places 
Sql :: sql order by number not ordered 
Sql :: how to change server name in sql server 
Sql :: insert many to many sql 
Sql :: drush SQLSTATE[HY000] [2002] No such file or directory 
Sql :: postgresql where and 
Sql :: mysql default uuid 
Sql :: how to comment in sql 
Sql :: sql insert into 
Sql :: sql insert exemplo 
Sql :: docker hub mysql 
Sql :: add column mysql with foreign key 
Sql :: oracle job class 
Sql :: how to delete last row in sql 
Sql :: add sqlite3 in lumen 
Sql :: get number of rows in every table mysql 
Sql :: create a plsql object 
Sql :: psql attribute cannot login 
Sql :: sqlalchemy query sql compiled 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =