Sub query, SQL, Oracle I’m new to sub queries and hoping to get some assistance. My thought was the sub query would run first and then the outer query would execute based on the sub query filter of trans_code = ‘ABC’. The query works but it pulls all dates from all transaction codes, trans_c…
Tag: oracle
Missing expression inside sub-query statement?
I am using the infamous “CityJail” schema to answer a question “List the names of all criminals who have committed more than average number of crimes and aren’t listed as violent offenders.” Here is my code: but I get an error: ORA-00936: missing expression 00936. 00000 – “…
Convert month and year as last day of the month in oracle sql
I have two column – Month and Year in a table. Need to concatenate these to get the last day of the month in date format. For example, if Month =5 and Year =2020, the output needs to 31-May-20. Similarly if Month =4 and Year=19, the output needs to be 30-APR-20. Any idea how this can be done, is there
Reading BLOB column in oracle table
I have a table tbl which has below columns: When I run below query it works fine: But when I run below it throws error: I mean to say, if I select only 1 blob column to read , then date filter works fine. But when I select both BLOB columns with date filter in where clause, it throws below
SQL: How to get salary format of “$99,999.00”
In my table, the salary is in format “99999”, how do I get it/select it into the format of “$99,999.00”? Answer You can use a format mask like the one below. Different format models can be found here.
what this sign mean in sql query
i have the following code : What is /*_archive*/ mean ? in my database we have : Answer From a /* sequence to the following */ sequence, as in the C programming language. This syntax enables a comment to extend over multiple lines because the beginning and closing sequences need not be on the same line. MySQL…
Oracle sql adding custom column name as 1st row of the resultSet
How do I get the column name as the 1st row of the result set.I tried below but getting the error as shown below Answer I would recommend two changes to your query. Change UNION to UNION ALL. This way your union will not look for duplicates between the two parts of the union. Since the first part of your
Oracle Merge – Can I do something like “When Not Matched Then Delete”?
I have a table (t1) with a unique list of patients. I have another table (t1_Backup) with a duplicative list of patients and details. I would like to essentially perform an inner join to update t1, …
Does using EXISTS instruction improves this query
Im learning how to improve some queries I have, for example I saw that using EXISTS over IN does better, so I did the following modification but im not 100% sure if im getting the same results I …
FOR loop in Oracle SQL or Apply SQL to multiple Oracle tables
My SQL is a bit rusty, so I don’t know whether the following is even possible: I have multiple tables t_a, t_b, t_c with the same column layout and I want to apply the same operation to them, namely output some aggregation into another table. For a table t_x this would look like this: I now want to exec…