Self-join of a subquery

前端 未结 3 1263
慢半拍i
慢半拍i 2021-02-04 02:53

I was wondering, is it possible to join the result of a query with itself, using PostgreSQL?

3条回答
  •  长发绾君心
    2021-02-04 03:14

    Yes, just alias the queries:

    SELECT  *
    FROM    (
            SELECT  *
            FROM   table
            ) t1
    JOIN    (
            SELECT  *
            FROM   table
            ) t2
    ON      t1.column < t2.other_column
    

提交回复
热议问题