Skip to content
Advertisement

How SQL can help to get required table format?

I have a query to know about valid and invalid database objects.

enter image description here

I am using this query:

I want to see the results in this table structure.

enter image description here

I am using Oracle 12.2

Advertisement

Answer

You can use conditional aggregation:

The count() function ignores nulls, so the case expressions give a not-null value when the condition is matched and those are counted. When the condition is not matched the implied else null (which you can add explicitly of course) gives null, and those are not counted.

In an environment I happen to be in that gives output:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement