i have the below table. i need to count the number of INTERFACES starting with FastEthernet2,FastEthernet5 and so on and group them by the NAME column.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
select name,
max(decode( rn,1,cn)) as FastEthernet2,
max(decode( rn,2,cn)) as FastEthernet5,
max(decode( rn,3,cn)) as FastEthernet6
from (
select name,
row_number() over (partition by name
order by name) rn,
count(*) cn from a
group by name,substr(INTERFACES,1,instr(INTERFACES,'/')-1)
) group by name;
I have to say this is a very interesting concept, kinda "reverse query troubleshooting" which if I get it right sounds like "if you can't get your query to work... change the data!"
I'm sure your business users would love the approach.
I'm wondering how it works with DBA's rule #37... "DBA do not owns the data, Business owns the data".
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Bookmarks