SELECT SUM() FROM (SELECT (SELECT ())
There is absolutely no problem whatsoever to achieve what you want. We don't see your entier query, but the most common problem is people forget to add an alias to their nested select
statement. Take a look at this sample that works perfectly :
select sum(col1) as sum1
from ( select col1
from ( select 1 col1 union all select 2 union all select 3 ) tmp
) tmp2
According to the OP, here is your final query :
SELECT SUM(numbers)
FROM (
SELECT columnA
AS
'numbers'
FROM tableA
WHERE clause
) tmp
You need an alias on the subquery:
SELECT SUM(numbers)
FROM
(
script -- your subquery will go here
) src -- place an alias here
So your full query will be:
select sum(numbers)
from
(
SELECT columnA AS numbers
FROM tableA
WHERE clause
) src