Skip to content

Tag: oracle

How to generate multiple combinations from tables using SQL?

I have few combinations of records in my table but i want to generate Multiple combinations from original table. Records in table codeset codevalue column system test1 1 null sys1 test2 2 col2 sys1 test3 3 col3 sys1 test3 4 col4 sys1 test3 5 col5 sys1 test4 null col6 sys1 test5 6 col7 sys2 test5 7 col8 sys2 A…

Unable to Convert to Date

I am trying to return just the date from a datetime field When I run the Select Claus with just the first line, it work as expected. But when I add the second line, I receive From keyword not found error. ORA-00923: FROM keyword not found where expected Answer In Oracle, DATE is a reserved word and you cannot…

Oracle INSERT with a CASE statement

I have the following table declaration and I’m trying to use a case statement to INSERT some rows and I’m getting the following error ORA-00976: Specified pseudocolumn or operator not allowed here. Can someone please let me know how to rectify the INSERT code. Thanks in advance to all who answer. …

How can I limit the max value of an SQL field?

I am trying to force the value of the field PRICE to be under 500 if is it paid with cash (PAYMENT = “CASH”), to make impossible to insert anything over that. The table (SALES) is something like this: ID (PK) [INT] | DATE [VARCHAR] | SHOP [VARCHAR] | PRICE [FLOAT] | PAYMENT [VARCHAR] I am almost n…

Oracle Hierarchical Query at depth level

I have a requirement to build a table from a hierarchical table. Table structure as below: emp_hier table: emp_id supervisorId 100 null 1 100 2 1 3 2 New table: I have to write a select query on the emp_heir table and the selected data should look like this: sel_emp_id rel_emp_id relation depth_lvl 100 100 se…