Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql select last row for each group

SELECT * 
FROM CUSTOMERS
WHERE id IN (SELECT  MAX(id) FROM CUSTOMERS GROUP BY PERSON_NAME);
Comment

mysql select each last value group by

SELECT `tbl`.*
FROM my_table `tbl` , (SELECT MAX(`status_on`) `last_status_on`, status_id FROM my_table
GROUP BY `status_id`) `tbl_lasts`
WHERE `tbl`.`status_on` = `tbl_lasts`.`last_status_on`
Comment

PREVIOUS NEXT
Code Example
Sql :: postgres convert text to number 
Sql :: sql alter table statement 
Sql :: how to fetch alternate records from two tables 
Sql :: sql drop database statement 
Sql :: oracle sql timestamp 
Sql :: mysql time ago difference 
Sql :: backup ms sql database table data to file 
Sql :: select count of distinct values sql 
Sql :: how to create an empty table from an existing table 
Sql :: how to get table current identity value in sql server 
Sql :: mysql persistence.xml 
Sql :: is there any command to change postgres password 
Sql :: mysql how to subtract dates 
Sql :: désinstaller postgresql linux 
Sql :: show size database mysql 
Sql :: how to change the value of a table in sql 
Sql :: uppercase and lowercase in sql 
Sql :: array out of range mql4 
Sql :: sql create table primary key autoincrement 
Sql :: brew start postgres manual 
Sql :: SQL: merging multiple row data in string 
Sql :: postgresql drop table 
Sql :: allsource oracle 
Sql :: insert data from another table 
Sql :: date format in sql 
Sql :: how to get id of last inserted row in mysql 
Sql :: duplicate table sql 
Sql :: drop table with constraints 
Sql :: mysqli last row 
Sql :: how to unlock table in sql server 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =