[pgsql-jp: 30410] Re: Intersectでの抽出結果のソート

sugita @ sra.co.jp sugita @ sra.co.jp
2003年 7月 6日 (日) 10:23:26 JST


  杉田です。

From: "yoshiki(R)HORIE" <yoshiki @ presence-inc.jp>
Subject: [pgsql-jp: 30353] Intersectでの抽出結果のソート
Date: Thu, 03 Jul 2003 09:48:48 +0900

;;; 堀江と申します。
;;; 
;;; 大変申し訳ございませんが、ご教授願います。
;;; クエリーAとBがあり、その積抽出をIntersectで行った場合、結果のソートは
;;; どのようなSQLコマンドがあるのでしょうか?

  簡単な実例が分かるとはっきりするのですが、以下のようなことでしょうか?

    =# (select * from class1 where id < 505) intersect (select * from class1 where id >= 495);
     id  | data
    -----+------
     495 |    5
     496 |    6
     497 |    7
     498 |    8
     499 |    9
     500 |    0
     501 |    1
     502 |    2
     503 |    3
     504 |    4
    (10 rows)

    =# (select * from class1 where id < 505) intersect (select * from class1 where id >= 495) order by data;
     id  | data
    -----+------
     500 |    0
     501 |    1
     502 |    2
     503 |    3
     504 |    4
     495 |    5
     496 |    6
     497 |    7
     498 |    8
     499 |    9
    (10 rows)

    =# 


Kenji Sugita                                      




pgsql-jp メーリングリストの案内