I want to count the values on a query result but within the same query if that makes sense. the origional query is
SELECT CLOSING_FEE+CLOSING_FEE_INT+CLOSING_INS+CLOSING_INT+CLOSING_OTHER as BAL, total_closing_balance
FROM statement
this returns over 4000 rows. I want to check the two add up. is there a way to use the count function in the same query to count the first two values of the select statement?
Or would i have to use something like a temp table and then count?
use Select sum(CLOSING_FEE+CLOSING_FEE_INT+CLOSING_INS+CLOSING_INT+CLOSING_OTHER )
it will add up all these details.
如果total_closing_balance是静态的,请尝试此操作
SELECT SUM(CLOSING_FEE+CLOSING_FEE_INT+CLOSING_INS+CLOSING_INT+CLOSING_OTHER) as BAL, MAX(total_closing_balance) AS total_closing_balance FROM isql.VW_300_statement WHERE brand = '1'AND DAT = '2013-01-18 00:00:00.00000'AND INS_TYPE =''group by Brand,DAT
In order to count the rows of a query result you have to write a query as following:
select count(*)
from (SELECT CLOSING_FEE+CLOSING_FEE_INT+CLOSING_INS+CLOSING_INT+CLOSING_OTHER as BAL, total_closing_balance
FROM isql.VW_300_statement
WHERE brand = '1'
AND DAT = '2013-01-18 00:00:00.00000'
AND INS_TYPE ='')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.