Count the numbers that are used in range - SQL
800012Sep 24 2010 — edited Sep 24 2010Dear Guru's,
I need a help to create a query.
My INPUT will be like
WITH s AS
(
SELECT 2 a, 7 b
FROM DUAL
UNION
SELECT 3 a, 3 b
FROM DUAL
UNION
SELECT 3 a, 6 b
FROM DUAL
UNION
SELECT 9 a, 15 b
FROM DUAL
UNION
SELECT 10 a, 10 b
FROM DUAL
UNION
SELECT 10 a, 15 b
FROM DUAL)
SELECT *
FROM s;
I need output like the distinct count of numbers. Consider column a as num_from and b as num_to. So the expected output here is 13. since all the numbers from 2 to 15 are in use expect 8. so my result would be 13. Kindly help me to reslove.
I am currently working in Oracle 10g database.
Thanks In Advance!
With Best Regards,
VJ