Skip to content
Advertisement

Tag: oracle

ORACLE SQL Combining many rows to one and sum a field

ORACLE SQL … I am trying to combine rows into one when they share the same contents in the following fields: In addition, I need the sum of the fields GL_ACCOUNT_BALANCE from all the respective previous rows to be totaled onto that one new row. I have written the following code. Answer From my point of view, code you posted

Using Right() or Substr() in an UPDATE statement

I have two tables : Second Table : I need to update the field HC_ID of Add_T Table and I use the following SQL statement: It doesn’t work. Also, I used the right() function and also got incorrect results. Could anyone say where is the mistake? Answer Looks like you need the last 4 characters of a string. If so,

sql join gives cumulative results

I want to join county and county_type tables and get only those county that doesnt have a type =30. From below example id = 1 and 3 should only be the expected output county output: Tried this: what i am getting is cumulative: Answer You want not exists:

spool to .csv file using for loop

need to spool output into .csv file using loop, fyi…I have data in 4 diff partition. but no sure how to proceed. code be like. result:- not sure if I am spooling properly, also please check the index variable of for loop in used correctly in my select statement. Answer You don’t need 4 different queries, just list all your

Oracle SQL get last Sunday [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year. Improve this question I am currently using the below statement to sucessfully get it Is there any more elegant way to get it? If I

Creating a SQL view that will accept inserted values

I have created a SQL view that retrieves the result set I desire but when I try to add a new set of values it fails. When searching around on the net it appears that VIEW has a few limitations and some types of joins may not be allowed, I have tried to create the view a few different ways

Scenarios andsSteps “get last change” problem

I have following table abstracting some scenarios and their steps ordered by START_DATE “desc”. SCENARIO_KEY STEP_KEY START_DATE END_DATE PREVIOUS_SCENARIO_KEY PREVIOUS_STEP_KEY 128 44 20xx04x4 0 120 44 120 44 20xx03x3 20xx04x4 120 38 120 38 20xx11x0 20xx03x3 121 38 121 38 20xx07x2 20xx11x0 120 44 120 44 20xx07x1 20xx07x2 120 38 I need to get first scenario_key (or another identifier) after

Oracle Sql- Adding column to pivot result

I’m have an issue that I’m not entirely sure how to fix. So I have a table of the format Where order_type is the column in question I use to pivot. Value is the column I’m using to run aggregates, but the problem is Units. So for each unique ID + order_type combo, units will be the same. But I’m

Oracle SQL combining table information and creating output

I have two tables in Oracle SQL developer and I am trying to figure out how to display “fname, ssn” and the employees corresponding manager “fname, snn”. Below are the tables that I have created but I cant seem to get the employee information to correspond to their subsequent manager. Employee Table Department Table Desired Output This is what I

Separate numeric values and character values in oracle

A table contains both numeric and character values in a column. The numeric values and character values need to be separated in different columns Col1 1 2 3 A B C The output needs to be col1 col2 1 A 2 B 3 C Answer You could do this using conditional aggregation: You cold simplify this a bit using a

Advertisement