select
d.name,
s.category,
(select AVG(s.retail)
from stock s1
where s1.dealerID = s.dealerID
and (s1.category = 'TOYOTA' or s1.category = 'HONDA') as AVERAGE_SALE_PRICE
from dealer d
join stock s using (dealerID)
我有同样的问题:
Name | ContactName | Address | City | PostalCode | Country
Alfreds | Maria Anders | Path 57 | Berlin | 12209 | Germany
Ana | Ana Trujillo | Kanne 22 | México | 05021 | Mexico
通常我应该得到Ana ..但是我得到了那些数据集。出于任何原因,PostalCode没有意识。
答案 0 :(得分:2)
您无法将OR
和AND
置于同一条件级别。保持逻辑你必须使用OR
的括号,如下所示
SELECT * FROM Customers
WHERE (Country Like '*m*' Or City Like '*m*')
And PostalCode='05021';
答案 1 :(得分:0)
这是@Parado
SELECT *
FROM Customers
WHERE (Country & City) LIKE '*m*'
AND PostalCode = '05021'
-------------------------------------------------
SELECT *
FROM Customers
WHERE (Country & City & PostalCode) = '*m*05021'
-------------------------------------------------
SELECT *
FROM Customers
WHERE (Country + City + PostalCode) = '%m%05021'