我有下面的查询,每次我改变它,我需要改变股票客户端i。我希望我只有一个where语句应用于所有子查询。
有没有一种方法可以应用相同的代码来返回多行?我希望显示所有股票客户I的结果,而不是只显示1个。
Select
(Select distinct SName FROM classifiedadmin.readOnly_CoreData) as SupplierName,
(SELECT COUNT(*) FROM classifiedadmin.readOnly_CoreData where Successful= 1 and StockClientID=3) as TotalLive,
(Select count(*) FROM classifiedadmin.readOnly_CoreData where length(DetailDesc) > 200 and StockClientID= 3) as DescriptionOver200,
(select count(*) from classifiedadmin.readOnly_CoreData where busruleViolated=1 and StockClientID = 3) as BusinessRuleViolated,
(Select count(*) FROM classifiedadmin.readOnly_CoreData where StockClientID = 3
and Successful=0
and busruleviolated=0
and Edition not like '%auto%'
and Edition not like '%shift%'
and Edition not like '%tronic%'
and Edition not like '%van%'
and Edition not like '%DSG%') as UnadvertisedManual;发布于 2010-10-29 19:54:20
SELECT MIN(sname),
SUM(Successful= 1),
SUM(length(DetailDesc) > 200),
SUM(busruleViolated=1),
SUM(
Successful=0
and busruleviolated=0
and Edition not like '%auto%'
and Edition not like '%shift%'
and Edition not like '%tronic%'
and Edition not like '%van%'
and Edition not like '%DSG%'
)
FROM classifiedadmin.readOnly_CoreData
WHERE StockClientID = 3请注意,如果给定的SELECT DISINCT sname中有多个sname,则当前使用stockclientid的查询将失败。
https://stackoverflow.com/questions/4051525
复制相似问题