SQL不包括两列组合上的重复值

SQL不包括两列组合上的重复值,sql,join,duplicate-removal,Sql,Join,Duplicate Removal,我正在编写sql-ex.ru中的练习16。该问题提出以下问题: Find the pairs of PC models having identical speeds and RAM. As a result, each resulting pair is shown only once, i.e. (i, j) but not (j, i). Result set: model with higher number, model with lower number, speed, and

我正在编写sql-ex.ru中的练习16。该问题提出以下问题:

Find the pairs of PC models having identical speeds and RAM. 
As a result, each resulting pair is shown only once, i.e. (i, j) but not (j, i). 
Result set: model with higher number, model with lower number, speed, and RAM.
数据库架构为:

Product(maker, model, type)
PC(code, model, speed, ram, hd, cd, price)
Laptop(code, model, speed, ram, hd, screen, price)
Printer(code, model, color, type, price)
我编写了以下查询:

SELECT A.model, B.model, A.speed, A.ram
FROM PC A
JOIN PC B ON (A.model<>B.model)
WHERE A.speed=B.speed
AND A.ram=B.ram
如您所见,i,j的值被翻转并作为不同的值计算。有没有一个简单的方法来消除这样的重复?我有点迷路了。

我认为问题陈述中的“数字较高的模型,数字较低的模型”是一条线索,表明你需要在某个地方有一个
a.model>B.model
条件。Join的
开启
状态听起来像是一个很好的候选者:

SELECT A.model, B.model, A.speed, A.ram
FROM PC A
JOIN PC B ON (A.model > B.model) -- <<<=== Here
WHERE A.speed=B.speed
AND A.ram=B.ram
选择A.model、B.model、A.speed、A.ram
从PC A

加入PC B ON(A.model>B.model)——这很有意义。没有考虑对称值。
SELECT A.model, B.model, A.speed, A.ram
FROM PC A
JOIN PC B ON (A.model > B.model) -- <<<=== Here
WHERE A.speed=B.speed
AND A.ram=B.ram