Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻求帮助以尝试解决查询问题。
询问:
SELECT distinct BRAND,(select count(distinct VIN) from STOCK) as STOCK ITEM COUNT from STOCK
我想要实现的是显示位于每个品牌中的所有 VIN 号码的品牌和唯一计数。
出于某种原因,当我运行上述查询时,每个品牌(例如福特、通用、丰田等)都显示相同的计数。
或者做一个简单的GROUP BY:
GROUP BY
SELECT BRAND, count(distinct VIN) as STOCK_ITEM COUNT from STOCK group by brand
您目前正在制作一个不考虑的子查询BRAND。你想使用GROUP BY:
BRAND
SELECT Brand, Count(*) FROM Stock GROUP BY Brand