I wish to modify data by selecting them in a inner query and count one of them modified.. It gives error..
我希望通过在内部查询中选择数据并计算其中一个数据被修改。它给错误. .
select count(cvs) from
(
select
cvs,
(case Citycode when 123 then 'test' else 'other' end) as CityName ,
(case ProductCode when '000' then 'test3' when 'ss' then 'xtr' else 'ddd' end) as CardName
from Applications
)
4 个解决方案
#1
47
you need to give an alias to the subquery:
您需要为子查询提供别名:
select count(x.cvs) from
(
select
cvs,
(case Citycode when 123 then 'test' else 'other' end) as CityName ,
(case ProductCode when '000' then 'test3' when 'ss' then 'xtr' else 'ddd' end) as CardName
from Applications
) x
#2
1
Why not just do this instead?
为什么不这样做呢?
SELECT COUNT(cvs)
FROM Applications
#3
0
It appears your query could be simplified to..
看来您的查询可以简化为。
SELECT COUNT(cvs) FROM Applications
Is there a reason you have the select nested and you are ignoring the other columns being selected?
有什么原因使您具有选择嵌套,而忽略了正在选择的其他列?
#4
0
Two things I see off the bat:
我立刻看到了两件事:
1 - You don't need the nested subquery for what you are doing in the example. You could just as easily do:
1 -在本例中,您不需要嵌套子查询。你也可以很容易地做到:
SELECT COUNT(cvs) FROM application
从应用程序选择计数(cvs)
2 - You need an alias for the subquery, like (<subquery>) as SubQ
2 -你需要一个子查询的别名,例如(
#1
47
you need to give an alias to the subquery:
您需要为子查询提供别名:
select count(x.cvs) from
(
select
cvs,
(case Citycode when 123 then 'test' else 'other' end) as CityName ,
(case ProductCode when '000' then 'test3' when 'ss' then 'xtr' else 'ddd' end) as CardName
from Applications
) x
#2
1
Why not just do this instead?
为什么不这样做呢?
SELECT COUNT(cvs)
FROM Applications
#3
0
It appears your query could be simplified to..
看来您的查询可以简化为。
SELECT COUNT(cvs) FROM Applications
Is there a reason you have the select nested and you are ignoring the other columns being selected?
有什么原因使您具有选择嵌套,而忽略了正在选择的其他列?
#4
0
Two things I see off the bat:
我立刻看到了两件事:
1 - You don't need the nested subquery for what you are doing in the example. You could just as easily do:
1 -在本例中,您不需要嵌套子查询。你也可以很容易地做到:
SELECT COUNT(cvs) FROM application
从应用程序选择计数(cvs)
2 - You need an alias for the subquery, like (<subquery>) as SubQ
2 -你需要一个子查询的别名,例如(