如何显示以下序列号
select count(*) toatl_count, "employee is Invalid" error from emp
union
select count(*) total_count, "comapny name is incorrect" error from company;
结果将会是
total_count error
10 employee is Invalid
55 comapny name is incorrect
但我需要如下输出
serial number total_count error
1 10 employee is Invalid
2 55 comapny name is incorrect
试试这个:
SELECT
ROW_NUMBER() OVER() AS serial_no,
total_count,
error
FROM (
SELECT count(*) total_count, '"employee is Invalid"' error FROM emp
UNION
SELECT count(*) total_count, '"company name is incorrect"' error FROM company
) subquery
ORDER BY serial_no;