I am new to SQL and was wondering if someone can help me with this small request. I am trying to have my output like down below: But I am currently getting this output: Here is my SQL code: How can I get the columns to reflect MF, CH_A, CH_B, and CH_C with its respective value? Answer @Med2020 Your query
Tag: oracle
How to find a destinct values in a table that are larger than all values that reference it?
I need to find the names of bosses who were hired after all the hired date of all their subordinates. Here is what I have got so far: SELECT DISTINCT TRIM(boss.first_name || ‘ ‘ || boss.last_name)…
Separate columns by commas ignoring nulls
I have the below table: A B C D E A1 null C1 null E1 A2 B2 C2 null null null null C3 null E3 I would like the below output (separated by commas, if any value is null, then do not add a comma): F A1, C1, E1 A2, B2, C2 C3, E3 Answer You can concatenate all columns
Adding column in table with the values in another if matched
I have two tables: table1 A B C A1 B1 C1 A2 B2 C2 A3 B3 C3 A4 B4 C4 A5 B5 C5 A6 B6 C6 table2 A D A1 D1 A3 D3 A5 D5 A6 D6 I would like to have table 1 updated with a column D which shows the value in column D joining by A. However,
Syntax errors while trying to use a select statement as the condition for a while loop in SQL
I have a simple loop I wrote to check if a random id is already in the table, else regenerate it: Running the code above gives the error: and As far as I can tell, no error in the editor. Answer The better approach is to collect all the id’s into a PL/SQL collection, so that you only make one
Optimize Merge query inside n^2 loop
I’ve got a merge query that needs to be executed one time for each combination of day and sessionType inside the request ArrayList. I am using nativeQuery to execute it. Is there a way to plain the source data (two ArrayLists, one with a date range instead a single day, and the other with all the sessio…
query to group remarks column with sum of other column in oracle
lets assume i have following table “marksheet”: Now I want it like this: I have tried this. Now, I want to add theory_remarks and practical_remarks as above (table2). Thank you for any help. Answer Assuming userid,subject,type is unique
Oracle SQL Developer – Getting value from cursor only works with one filter (AND / OR) clause
I am attempting to write a query to retrieve a value from multiple databases and write it to a file. In my function I have a statement which returns results from the cursor: When I try to modify the filter to add another filter, the results are Null: Why would the additional filter remove the results? Here is…
Updating all the record for a column in a table with value from another table
Hi I want to update all the values of RequestId column of IIL_CHANGE_REQUEST Table with the RequestId of TABLE_NAME_4MINS Table where REQUESTBY column in both tables are same. I am trying to do this in oracle daatabalse(sql developer) My query: But every time I do this I get an error saying: Error report R…
How to check instring for alphanumeric values
I have the following dataset: I need to check whether or not one of the comma separated values is an alphanumeric value. How can I do this? Answer This could be one option; read comments within code.