DB version: 11.1.2.3.0
I am using the below SQL:
SELECT tab_nam, cnt
FROM
(
SELECT 'Tab1' "tab_nam", COUNT(1) "cnt" FROM Tab1
UNION
SELECT 'Tab2' "tab_nam", COUNT(1) "cnt" FROM Tab2
);
TAB_NAM CNT
------- ------
Tab1 23
Tab2 10
CREATE TABLE Tab1 (id NUMBER, name VARCHAR2(100));
CREATE TABLE Tab2 (id NUMBER, name VARCHAR2(100));
Is there any other way to get the output in the above form? I would like to get the resultset in above format only and not horizontally..
Reason for different SQL: I am not able to print the SQL output to HTML. Format used:
PRO <h3>Table Count</h3>
PRO <table>
PRO <tr>
PRO <th>Table Name</th>
PRO <th>Count</th>
PRO </tr>
SELECT '<tr>'||
'<td class="left">'||"tab_name"||'</td>'||
'<td class="center">'||"cnt"||'</td>'||
'</tr>'
FROM (
SELECT 'Tab1' "tab_name", COUNT(1) "cnt" FROM Tab1
UNION
SELECT 'Tab2' "tab_name", COUNT(1) "cnt" FROM Tab2);
PRO </table>
Tia..
UNIONquery by itself.