我试图编写一条SQL语句,该语句将返回出口超过" 500"从我的数据库。我的问题是,我的查询不是返回不符合条件的国家,而是返回那些国家/地区,除了将null作为导出值。
TRANSFORM Sum(TradeInfo.Amount) AS SumOfAmount
SELECT Country.CountryName
FROM Country INNER JOIN TradeInfo ON Country.CountryID = TradeInfo.CountryID
WHERE (((TradeInfo.year)=2000) AND ((TradeInfo.Tradetype)="export") AND ((TradeInfo.Amount)>=500)) OR (((TradeInfo.year)=2013) AND ((TradeInfo.Tradetype)="export")) AND ((TradeInfo.Amount)>=500)
GROUP BY Country.CountryName, TradeInfo.Amount
PIVOT TradeInfo.Year;
答案 0 :(得分:0)
而不是使用
WHERE(((TradeInfo.year)= 2000)AND((TradeInfo.Tradetype)=“export”)AND((TradeInfo.Amount)> = 500))OR(((TradeInfo.year)= 2013) AND((TradeInfo.Tradetype)=“export”))AND((TradeInfo.Amount)> = 500)
使用 WHERE(((TradeInfo.year)= 2000)AND((TradeInfo.Tradetype)=“export”)AND(((TradeInfo.year)= 2013)AND((TradeInfo.Tradetype)=“export”))AND(( TradeInfo.Amount)> = 500)和(TradeInfo.Amount)> = 500