![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Illegal symbol "<EMPTY>", Some symbols that might be legal are: CORRELATION NAME. (SQL code = -104, SQL state =42601) Perhaps you are using older version of DB2. |
#3
| |||
| |||
|
|
select sum(used) from ( select count(*) as "used" from ur.agncy where agncy_id >= '2283' and agncy_id <= '2329' union select count(*) as "used" from ur.agncy where agncy_id >= '2922' and agncy_id <= '2994' ) AS q Some issues. |
#4
| |||
| |||
|
|
Here is an example of rewrite. SELECT SUM(used) * FROM ( * * * *SELECT COUNT(*) as used * * * * *FROM ur.agncy * * * * WHERE agncy_id BETWEEN '2283' AND '2329' * * * *UNION ALL * * * *SELECT COUNT(*) as used * * * * *FROM ur.agncy * * * * WHERE agncy_id BETWEEN '2922' AND '2994' * * * *) AS q ; Or, simply... |
#5
| |||
| |||
|
|
to get total count from each section first and then get the total counts of all sections |
#6
| |||
| |||
|
|
to get total count from each section first and then get the total counts of all sections Get "count from each section" and "total counts" at once. SELECT CASE GROUPING(section) * * * *WHEN 1 THEN * * * * * * 'All sctions' * * * *ELSE section * * * *END *AS section * * *, SUM(used) AS count * FROM ( * * * *SELECT 'Section one' * * * * * * , COUNT(*) * * * * *FROM ur.agncy * * * * WHERE agncy_id BETWEEN '2283' AND '2329' * * * *UNION ALL * * * *SELECT 'Section two' * * * * * * , COUNT(*) * * * * *FROM ur.agncy * * * * WHERE agncy_id BETWEEN '2922' AND '2994' * * * *) AS q (section , used) *GROUP BY * * * *ROLLUP(section) ; |
#7
| |||
| |||
|
|
to get total count from each section first and then get the total counts of all sections Get "count from each section" and "total counts" at once. Another example(returns one row): |
![]() |
| Thread Tools | |
| Display Modes | |
| |