SQL: Select only one row of table with same value

Z3r0byte

Im a bit new to sql and for my project I need to do some Database sorting and filtering:

Let's assume my database looks like this:

==========================================
|  id       |       email        | name
==========================================
|   1       |  [email protected]      | John
|   2       |  [email protected]      | Peter
|   3       |  [email protected]      | Steward
|   4       |  [email protected]      | Ethan
|   5       |  [email protected]      | Bob
|   6       |  [email protected]      | Patrick
==========================================

What should I do to only have the last column with the same email te be returned:

==========================================
|  id       |       email        | name
==========================================
|   3       |  [email protected]      | Steward
|   5       |  [email protected]      | Bob
|   6       |  [email protected]      | Patrick
==========================================

Thanks in advance!

Saibal Roy

SQL Query:

    SELECT * FROM test.test1  WHERE id IN (
  SELECT MAX(id) FROM test.test1 GROUP BY email
);

Your sample dataset Query result

Hope this solves your problem. Thanks.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

SQL: Select only one row of table with same value

From Dev

Insert new SQL row only if there is same value from other table

From Dev

MS SQL - Select only one row for an ID

From Dev

How to reload a value in only one row of table

From Dev

PIVOT table only in one row in SQL Server?

From Dev

Select unique pairs of rows from one table that are associated to the same value in another table in SQL

From Dev

In SQL how to not select rows where a column value is the same as the one in the row above it

From Dev

Select only one checkbox/radiobutton in the same row and column

From Dev

Select and update same table and row in one connection in mysql

From Dev

SQL query to select row from one table which is not in another table

From Dev

Use sqlalchemy to select only one row from related table

From Dev

MySQL - How to select only two columns from a row in one table

From Dev

Select TOP 5 only returning one row when called through code, where same script returns 5 rows in SQL Server

From Dev

SQL or PL/SQL to return the value of nodes with same name to one row

From Dev

Select rows where field in joining table not same value in every row

From Dev

select value from same row using case on table oracle

From Dev

Select rows where field in joining table not same value in every row

From Dev

How to select all from table one based on a value, then select from same table with value from that table?

From Dev

PostgresSQL Copy a row to the same table and alter one value

From Dev

To copy a row and insert in same table with a one different value for a field in MySQL

From Dev

sql query select only one row from multiple rows

From Dev

SQL Select Text for multiple foreign keys to lookup table in same row

From Dev

Select corresponding to row from the same table SQL Server

From Dev

SQL LIKE search error only on one row of table

From Dev

Update row with select on same table

From Dev

SQL Server: increment row number only one value

From Dev

Mysql Query select one row from the same values (select duplicate only)

From Dev

Only select one record if there are more than one of only certain same value of record

From Dev

How to insert a row having only one column different than the other row in the same table?

Related Related

  1. 1

    SQL: Select only one row of table with same value

  2. 2

    Insert new SQL row only if there is same value from other table

  3. 3

    MS SQL - Select only one row for an ID

  4. 4

    How to reload a value in only one row of table

  5. 5

    PIVOT table only in one row in SQL Server?

  6. 6

    Select unique pairs of rows from one table that are associated to the same value in another table in SQL

  7. 7

    In SQL how to not select rows where a column value is the same as the one in the row above it

  8. 8

    Select only one checkbox/radiobutton in the same row and column

  9. 9

    Select and update same table and row in one connection in mysql

  10. 10

    SQL query to select row from one table which is not in another table

  11. 11

    Use sqlalchemy to select only one row from related table

  12. 12

    MySQL - How to select only two columns from a row in one table

  13. 13

    Select TOP 5 only returning one row when called through code, where same script returns 5 rows in SQL Server

  14. 14

    SQL or PL/SQL to return the value of nodes with same name to one row

  15. 15

    Select rows where field in joining table not same value in every row

  16. 16

    select value from same row using case on table oracle

  17. 17

    Select rows where field in joining table not same value in every row

  18. 18

    How to select all from table one based on a value, then select from same table with value from that table?

  19. 19

    PostgresSQL Copy a row to the same table and alter one value

  20. 20

    To copy a row and insert in same table with a one different value for a field in MySQL

  21. 21

    sql query select only one row from multiple rows

  22. 22

    SQL Select Text for multiple foreign keys to lookup table in same row

  23. 23

    Select corresponding to row from the same table SQL Server

  24. 24

    SQL LIKE search error only on one row of table

  25. 25

    Update row with select on same table

  26. 26

    SQL Server: increment row number only one value

  27. 27

    Mysql Query select one row from the same values (select duplicate only)

  28. 28

    Only select one record if there are more than one of only certain same value of record

  29. 29

    How to insert a row having only one column different than the other row in the same table?

HotTag

Archive