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
)
A nested SELECT is a query within a query, i.e. when you have a SELECT statement within the main SELECT.
For example, you can use subqueries in the SELECT, FROM, WHERE, or HAVING clauses. A subquery may return either a single value or multiple rows. A single value is also known as a scalar value.
A subquery can be nested inside the WHERE or HAVING clause of an outer SELECT , INSERT , UPDATE , or DELETE statement, or inside another subquery.
Example -1 : Nested subqueries SELECT job_id,AVG(salary) FROM employees GROUP BY job_id HAVING AVG(salary)< (SELECT MAX(AVG(min_salary)) FROM jobs WHERE job_id IN (SELECT job_id FROM job_history WHERE department_id BETWEEN 50 AND 100) GROUP BY job_id); The above code is executed in Oracle 11g Express Edition.
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
Why not just do this instead?
SELECT COUNT(cvs)
FROM Applications
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With