SQL-SELECT DISTINCT 및 ORDER BY Latest

user1320260

gameName내 데이터베이스 에서 모든 고유 한 레코드 를 선택하고 싶습니다 . 현재 다음 SQL (간체)을 통해이 작업을 수행합니다.

SELECT DISTINCT gameName FROM myTable ORDER BY gameName;

테이블 구조

id  | gameName   |  modified
__________________________________________
1     foo          2014-12-21 19:24:59
6     goo          2014-12-18 14:24:59
8     foo          2015-01-01 11:24:59
21    doo          2014-11-23 21:24:59
32    foo          2014-10-01 19:24:59
3     doo          2014-08-15 22:24:59

산출

doo
foo
goo

이 SQL을 수정 gameName하여 최신 modified날짜로 구별 한 다음 최신 날짜로 주문하려고 modified합니다. 원하는대로 결과를 얻지 못했습니다.

원하는 출력

foo          2015-01-01 11:24:59
goo          2014-12-18 14:24:59
doo          2014-11-23 21:24:59

그것이 어떤 차이가 있다면 나는 PDO어떤 도움을 사용하고 있는지 크게 감사하겠습니다.

Milen

이 시도:

SELECT gameName , Max(modified) as modified
FROM myTable 
GROUP BY gameName 
ORDER BY gameName;

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Linq to SQL order by with Distinct

분류에서Dev

SQL Select Distinct 열 및 최신 날짜

분류에서Dev

SQL request with ORDER, DISTINCT and COUNT

분류에서Dev

SQL select distinct entity - union all - order by another entity's column

분류에서Dev

Distinct 및 Order by Desc를 사용한 SQL 내부 조인

분류에서Dev

MySQL SELECT 및 ORDER BY

분류에서Dev

SQL SELECT DISTINCT 및 GROUP BY 쿼리가 작동하지 않음

분류에서Dev

SQL Distinct based on two columns Order By count

분류에서Dev

SQL Inner Join using Distinct and Order by Desc

분류에서Dev

PostgreSQL Select latest 및 by other clause

분류에서Dev

SQL Select Count Distinct with WHERE 절

분류에서Dev

Zend2 Sql\Select add distinct

분류에서Dev

SQL 쿼리 SELECT DISTINCT WHERE BY

분류에서Dev

SQL : Distinct 및 OrderBy 문제

분류에서Dev

SQL Server : DISTINCT 및 MAX 표시 순서 값을 가져 오는 SELECT 쿼리

분류에서Dev

ORDER BY items must appear in the select list if SELECT DISTINCT is specified when using Calculated ORDER BY

분류에서Dev

SQL-ORDER 테이블 및 SELECT 모든 행 25 이후

분류에서Dev

SQL & PHP의 'SELECT DISTINCT CASE WHEN'문에서 'ORDER BY'문을 사용하는 방법은 무엇입니까?

분류에서Dev

Select rows from database where the value in one column is distinct and limit to 5 latest

분류에서Dev

PostgreSQ : JOIN SELECT 및 ORDER 숨김

분류에서Dev

여러 열이있는 SQL Select Distinct

분류에서Dev

SQL SELECT DISTINCT 그룹의 최신 줄

분류에서Dev

Sytax error when select distinct rows in a sql table

분류에서Dev

Select distinct rows where all values in a column are the same SQL Server

분류에서Dev

SQL Server를 사용한 DISTINCT 및 GROUP BY

분류에서Dev

Oracle Sql: Select only the latest records by an id and a date

분류에서Dev

SQL SERVER의 ORDER BY 및 CASE

분류에서Dev

PostgreSQL : SELECT DISTINCT 대 SELECT DISTINCT ON (id)

분류에서Dev

ORDER BY 및 SELECT 동일한 계산

Related 관련 기사

  1. 1

    Linq to SQL order by with Distinct

  2. 2

    SQL Select Distinct 열 및 최신 날짜

  3. 3

    SQL request with ORDER, DISTINCT and COUNT

  4. 4

    SQL select distinct entity - union all - order by another entity's column

  5. 5

    Distinct 및 Order by Desc를 사용한 SQL 내부 조인

  6. 6

    MySQL SELECT 및 ORDER BY

  7. 7

    SQL SELECT DISTINCT 및 GROUP BY 쿼리가 작동하지 않음

  8. 8

    SQL Distinct based on two columns Order By count

  9. 9

    SQL Inner Join using Distinct and Order by Desc

  10. 10

    PostgreSQL Select latest 및 by other clause

  11. 11

    SQL Select Count Distinct with WHERE 절

  12. 12

    Zend2 Sql\Select add distinct

  13. 13

    SQL 쿼리 SELECT DISTINCT WHERE BY

  14. 14

    SQL : Distinct 및 OrderBy 문제

  15. 15

    SQL Server : DISTINCT 및 MAX 표시 순서 값을 가져 오는 SELECT 쿼리

  16. 16

    ORDER BY items must appear in the select list if SELECT DISTINCT is specified when using Calculated ORDER BY

  17. 17

    SQL-ORDER 테이블 및 SELECT 모든 행 25 이후

  18. 18

    SQL & PHP의 'SELECT DISTINCT CASE WHEN'문에서 'ORDER BY'문을 사용하는 방법은 무엇입니까?

  19. 19

    Select rows from database where the value in one column is distinct and limit to 5 latest

  20. 20

    PostgreSQ : JOIN SELECT 및 ORDER 숨김

  21. 21

    여러 열이있는 SQL Select Distinct

  22. 22

    SQL SELECT DISTINCT 그룹의 최신 줄

  23. 23

    Sytax error when select distinct rows in a sql table

  24. 24

    Select distinct rows where all values in a column are the same SQL Server

  25. 25

    SQL Server를 사용한 DISTINCT 및 GROUP BY

  26. 26

    Oracle Sql: Select only the latest records by an id and a date

  27. 27

    SQL SERVER의 ORDER BY 및 CASE

  28. 28

    PostgreSQL : SELECT DISTINCT 대 SELECT DISTINCT ON (id)

  29. 29

    ORDER BY 및 SELECT 동일한 계산

뜨겁다태그

보관