Skip to content

Tag: oracle

Oracle query all_tab_columns.data_default (type LONG)

I have run this query: But it throws an error at column DATA_DEFAULT: ORA-00932: inconsistent datatypes: expected CHAR got LONG 00932. 00000 – “inconsistent datatypes: expected %s got %s” How can I fix that? Thanks! Answer You can’t do anything with a LONG. It’s a PITA that Oracl…

Oracle: Count non-null fields for each column in a table

I need a query to count the total number of non-null values for each column in a table. Since my table has hundreds of columns I’m looking for a solution that only requires me to input the table name. Perhaps using the result of: to get the column names and then a subquery to put counts against each col…

number formatting 9’999.00

I’d like to format a number in a SQL select like this How can I do this? It works for 9,999,999 with the following command Answer You are almost there. Just replace group separator (.) with a single quote (‘) and you are good to go. result:

Converting an Oracle date (stored as a number) in a SQL OPENQUERY

I am trying to create a number of stored procedures in SQL accessing an Oracle database. All dates in Oracle are stored as a 10 digit number which is causing some confusion. I have designed some dynamic SQL which allows us to run an OPENQUERY to pick out parameters however what I want to be able to do is use

How to simplify nested select in where clause?

I have 4 tables EMPLOYEE, COMPANY, WORKS and MANAGES. The tables are defined as follows- I need to find all the employees who live in the same city as the company for which they work. So far I have done this. It’s working fine. But I want to know is there any simpler way to do this query? Answer You