我有一个包含CustomerIDs和SalespersonIDs的表(order_t),我想要显示与所有与其关联的CustomerIDs的SalespersonIDs。SQL获取非重复值[Oracle SQL * Plus]
我尝试使用SELECT DISTINCT
SELECT DISTINCT salespersonid, customerid
FROM order_t;
但是,这将重复salespersonids。
这里有一个表样品
salespersonid customerid
--------------- ---------------
15 1
15 2
15 3
16 4
16 5
17 6
而且我想这个数据集作为结果
salespersonid customerid
--------------- ---------------
15 1
2
3
16 4
5
17 6
18 4
5
9
这完全
BREAK ON sid
SELECT DISTINCT salespersonid sid, customerid cid
FROM ORDER_T
ORDER BY salespersonid;
是的,所有这一切。 – StudentJ 2011-06-09 17:11:54