Update based on the missing values
Hello
I'm new to sql, attempted to retrieve results for the below scenario, but not able to do. Please let me know how I can do this.
I created the sample data below
create table id_data_upd (ID, ID_EXT, ID_VER) as
Select '12', '123', 1' Union double all the
Select '12', '345',' ' of all the double union
Select '12', '446', "of all the double union
Select ' 21 ', ' 2156', "of all the double union
Select ' 22 ', ' 2346', 1' Union double all the
Select ' 22 ', ' 2846', '0' of all the double union
Select ' 22 ', ' 3456', '0' of all the double union
Select ' 32 ', ' 4512', 1' Union double all the
Select ' 33 ', ' 4942', '0' of all the double union
Select '33', '5639', '0' double;
My data source is
ID | ID_EXT | ID_VER |
12 | 123 | 1 |
12 | 345 | |
12 | 456 | |
21 | 2156 | |
22 | 2346 | 1 |
22 | 3456 | 0 |
22 | 32542 | 0 |
32 | 4512 | 1 |
33 | 4942 | 0 |
33 | 5639 | 0 |
I'm trying to update the data for power two conditions
(1) If for the same id, there are a several ID_EXT and also check if the ID_VER = 1, then all other documents with this ID the ID_VER should be updated 0
(2) if there is a single record ID with ID_EXT unique with on no matter what ID_VER must be updated to iD_VER as 1
Data in the target after updates
ID | ID_EXT | ID_VER |
12 | 123 | 1 |
12 | 345 | 0 |
12 | 456 | 0 |
21 | 2156 | 1 |
I tried the County of ID_EXT (having count (ID_EXT) = 1), but records that should not be coming are also coming.
Please tell me how I can do this.
Best regards and thanks,
Quentin
Hello
Try this
4d68a426-e5d3-4f8c-A933-bb16364ea560 wrote:
Hi Frank,.
I expect the output as below.
ID ID_EXT ID_VER 12 123 1 12 345 0 12 456 0 21 2156 1 22 2346 1 22 3456 0 22 32542 0 32 4512 1 33 4942 0 33 5639 0
Thank you
Quentin
with t as ( -- start sample data select '12' id, '123' id_ext , '1' id_ver from dual union all select '12', '345' , ' ' from dual union all select '12', '446' , '' from dual union all select '21', '2156' , '' from dual union all select '22', '2346' , '1' from dual union all select '22', '2846' , '0' from dual union all select '22', '3456' , '0' from dual union all select '32', '4512' , '1' from dual union all select '33','4942' , '0' from dual union all select '33', '5639' , '0' from dual ) -- end sample data select id,id_ext,id_ver, case when row_number () over (partition by id order by id_ver desc nulls last) > 1 then '0' else nvl(id_ver,'1') end new_id_ver, nvl(case when row_number () over (partition by id order by id_ver desc nulls last) > 1 then '0' end,'1') maybe_new_id_ver from t
Tags: Database
Similar Questions
-
Update based on the max value of different tables.
{code}
create the table rule_table (number rule_id);
insert into rule_table values (10);
insert into rule_table values (20);
insert into rule_table values (30);
insert into rule_table values (40);
create the table auth_table (number of auth_id, rule_id number);
insert into auth_table values (1000, 10);
insert into auth_table values (2000, 10);
insert into auth_table values (3000, 10);
insert into auth_table values (4000, 20);
insert into auth_table values (5000, 20);
insert into auth_table values (6000, 30);
insert into auth_table values (7000, 30);
insert into auth_table values (8000, 40);
insert into auth_table values (9000, 40);
create the table pay_table (pay_id number, auth_id number, pay_indicator number);
insert into pay_table values (11111, 1000, 0);
insert into pay_table values (22222, 1000, 1);
insert into pay_table values (33333, 1000, 0);
insert into pay_table values (44444, 2000, 0);
insert into pay_table values (55555, 2000, 1).
insert into pay_table values (66666, 2000, 0);
insert into pay_table values (77777, 3000, 0);
insert into pay_table values (88888, 3000, 0);
insert into pay_table values (99999, 4000, 0);
insert into pay_table values (111111, 4000, 0);
insert into pay_table values (222222, 5000, 0);
insert into pay_table values (333333, 5000, 0);
insert into pay_table values (444444, 6000, 0);
insert into pay_table values (555555, 7000, 1);
insert into pay_table values (666666, 8000, 0);
insert into pay_table values (777777, 9000, 0);
insert into pay_table values (888888, 9000, 1);
create the table rule_pay (rule_id number, pay_max_indicator number);
insert into rule_pay values (10, 0);
insert into rule_pay (20, 0) values;
insert into rule_pay (30, 0) values;
insert into rule_pay (40, 0) values;
{code}
My intention is:
for every find of rule_id on the maximum pay_indicator (tables 3 query to get the max Show pay_indicator below) and on the other table I have to update this value max based on rule_id.
with max_tab
as
(
Select a.rule_id, max (pay_indicator) pay_indicator
rule_table a.,
b auth_table,
c pay_table
where a.rule_id = b.rule_id
and b.auth_id = c.auth_id
A.rule_id group
)
Update rule_pay
Set pay_max_indicator = (select max_tab.pay_indicator
of max_tab
where max_tab.rule_id = rule_pay.rule_id)
where
rule_id in (select rule_id from max_tab);
The above query does not.
Any help or suggestions are greatly appreciated.
Something like that?
SQL > select * from rule_pay;
RULE_ID PAY_MAX_INDICATOR
-------------------- --------------------
10 0
20 0
30 0
40 0
SQL > fusion in rule_pay PR
2. using (select a.rule_id, max (pay_indicator) pay_indicator
rule_table 3A,
auth_table 4 b,
pay_table 5 c
6 where a.rule_id = b.rule_id
7 and b.auth_id = c.auth_id
Group 8 by a.rule_id
9 ) u
10 on (u.rule_id = rp.rule_id)
11 when matched, then update
12 set rp.pay_max_indicator = u.pay_indicator
13;
4 lines merged.
SQL > select * from rule_pay;
RULE_ID PAY_MAX_INDICATOR
-------------------- --------------------
10 1
20 0
30 1
40 1
BTW, you can't put a WITH clause before an update. It can only precede a select statement.
-
based on the prompt value see the FDF anayasis
Hello
I have a situation like this
I use obiee 11g
Based on the prompt value in him would like to show 3 different analayses.
I mean that if the value of guest in the page has as abc data it should show the anlaysis1
If the prompt value data as def it should show the anlaysis2
If the prompt value data as the IGS, it should show the anlaysis3
If the prompt value data as jkl it should show the anlaysis3
Why 3 diff analysis is because I have my list 2 columns in each anayaiss and they are 3 different tables.
One more thing
Obiee do we have a show and a return value for a radiobutton/drop-down list. As show us abc how invites and returns 1. is possible?
Thank you
Published by: user123 on July 12, 2011 12:29You can have n number of reports, simply use the union all in the dash prompt sql results and this will give you the choice to select any report you want.
-
How to find the bpel instance in 11 g based on the index values
We have 10 GB BPEL processes where we define the 4 index values for all instances. Whenever the support request comes, ask us the values of index and based on what we're looking for the process instance.
We have now migrated bpel 10g and 11g process. How to find the bpel instance in 11 g based on the index values?You can go there. http://soasphere.blogspot.com/2011/04/how-to-Serch-composites-for-index.html. Do a join on the cube_instance and ci_indexes tables.
-
The Master Table column updated based on the sum of column Table detail
With the help of JDev 11.1.1.6.I have a master-detail table based on a link to BC.
The main table has a column that displays an InputText or an OutputText, based on the value in another column.
If the InputText is displayed, the user can enter a value and the database will be updated with that value.
If the OutputText is displayed, it must be a sum of a column in the secondary table. Also, this value will be written in the database.
Question:
How can I fill the OutputText in the main table with the sum of the values in a column in the secondary table?
The detail table column is a manually entered InputText field.
Thank you.
Create a spike in the main table and write in its expression as follows - DetailVoAccessorName.sum ("ColumnName");
This will calculate the sum of column table detail and then you can set the value of the transient attribute to attribute DB on backup operation
Ashish
-
void / vi based on the Boolean value
Hello
I have a main vi and I want to call a subvi based on a Boolean value, that is when the Boolean entry gets the true value, the sub - vi must run, otherwise it shouldn't.
To do this, I added the Boolean control component connector of the sub - vi and I added a while loop in the sub - vi, which has 'continue if true' condition. I also made this point prescribed to the subvi.
However, I noticed that even if the Boolean value false maintains execution of the sub - vi.
Can you get it someone please let me know what the problem with this approach?
Thank you
Despres
Put the Subvi code (or the Subvi set) inside the true case of a case structure and wire your boolean to that. I prefer the second option.
-
Change the text displayed, based on the threshold value
Hi users of Labview,.
I need help with display and editing text in labview.
The text should display and change according to the following conditions:
0 volt - "no power".
1 volt - "controller ON".
2 Volt - "Rotor Running"
3 volt - "Rotor stopped".
Based on the voltage read by the channel, the text must be displayed and modified on the same area of the front panel. For example, initially it will be 0 Volt and the text "No power" should appear as an indicator of text (and not as a warning message). He needs to change ' controller we ' when the chages of voltage from 0 to 1 volt. The canal reads the analog input voltage (range 0 - 5V).
I'm relatively new to labview. So please give me pointers or from suggestions on how can be done. Any help is greatly appreciated.
Thank you
REDA
Hello
Thanks for the crossrulz of notes, have not used the front threshold. For this simple example, it is "symmetrical", but I can see how the values in the table have been does not correspond to the index position that is so true useful. Learn something every day, I could not resist, wanted to try.
OK, here's a sample VI that puts a custom message based on the crossing of a threshold. Home work is to study the components before asking to :-)
The dice are the analog signal of 0 to 6. He rounded to the whole number to provide the index number. Power is the index number in the index table, the table being hard-coded text messages.
Two additional indicators may be deleted, useful to see what is happening.
And get rid of the value 0 if you want the text to match the number, he he he
Enjoy.
-
ListView, title change to header based on the stored value.
Hello
I'm new to native development, always trying to get a hang of how things are done in QML. I was wondering how it was possible to format the header in the ListView based on the value of the header. For example, the datamodel is sorted by name and status. Status is stored as an integer 0,1,2,3,4,5 in the database. Whenever the ListView displays the headers, I want to show the actual title of the State (for example in progress, completed) instead of display 0 or 1.
Thank you for your help.
If... else if... else must have worked well, please send your code.
-
Dynamically set a value based on the selected value of LOV
Apex 4.2
I can't create a dynamic action to set a value. I have used dynamic actions to hide and display areas but for some reason any cannot set a value.
I have a list of selection-> P101_LIST. Type of source is "Column of the database". Source of value or an expression is "person_id" the query is as follows:
Select first_name, person_id From Persons
I have a display-> P101_DISPLAY value. Source type is 'static Assignment. The source value or expression that I left blank.
I would like for each time the user selects a name of P101_LIST, the P101_DISPLAY element is updated to display the value (person_id) correspondent.
Because there are other page elements / information on the page, I prefer that to not submit / update of the page. Would not want other page elements / information update.
Any help on this would be greatly appreciated. Thanks in advance.
Hello
Create a DA:
-event onChange P101_LIST
-Action: PL/SQL
-PL/SQL code:
: P101_DISPLAY: =: P101_LIST;
What to submit: P101_LIST
Point of return: P101_DISPLAY
And in fact.
Kind regards
Joni
-
Increment sequence based on the existence value
Hello
I have a requirement,
I need the value sequence based on the values exist in the database.
Let me explain with an example of a column, I have values such as 1,2,3,4,5,6,7,8,10,12,14, etc...
Here I have to generate the value of the sequence 9,11,13 follows...
Logically it please suggest me... I try with While loop I could not reach again.
We want to help you.
Concerning
Rambeauselect level missing_values from dual connect by level <= (select max(your_column) from your_table) minus select your_column from your_table /
For example:
with t as ( select level n from dual connect by level < 9 union all select 10 from dual union all select 12 from dual union all select 14 from dual ) -- end of on-the-fly data sample select level missing_values from dual connect by level <= (select max(n) from t) minus select * from t / MISSING_VALUES -------------- 9 11 13 SQL>
SY.
-
Conditional display in the text box based on the calculated value
Hello
I have radio buttons that each have a numerical value. For example = 1 A = 2 C = 0. In the example below, the total is equal to 5.
The sum is displayed at the bottom of the document and is passed to another text box:
Instead of '5' displayed in the text box on the right, it should display a "Control" Word like this:
The displayed word is based on the totals through this range:
1-2 = 'absorbing '.
3-4 = 'practitioner '.
5 to 6 = "control".
The script I used to pass the value from the left to the right text box in the chart above is:
name of the field to text box;
var cTextBox = 'Cabinet Talent strategy knowledge - total';
get the value of the field with the name in cTextBox;
var sTextBox = this.getField ("cTextBox") .value;
Set the value of this field;
Event.Value = sTextBox;
That I need to add to this script to show one of the words, such as "control" above?
I am a complete novice to scripting. I found the above script online and somehow got it to work.
I thank very much for any help or pointers, you can provide.
Best regards
Sorry, there were some errors in the code that I provided above. Try this:
If (sTextBox > = 1 & sTextBox)<= 2)="">=>
Event.Value = "absorbing";
} ElseIf (sTextBox > = 3 & sTextBox)<= 4)="">=>
Event.Value = "practitioner";
} ElseIf (sTextBox > = 5 & sTextBox)<= 6)="">=>
Event.Value = "master";
} else {}
Event.Value = "";
}
If it still does not respond, you can send me the file at [email protected] and I'll check...
-
Make visible subform based on the dropdown value
I use this script successfully.
Form1. #subform [0]. typeOfIncidentDdl::change - (JavaScript, client)
assocInfoSubform.presence = 'hidden ';
custInfoSubform.presence = 'hidden ';If (xfa.event.newText == "associate injuries") {}
assocInfoSubform.presence = "visible";
} else {}
custInfoSubform.presence = "visible";
}But I would like to know how can I use numeric values in the object palette instead. For a drop-down list in the object > tab link, I click on the checkbox 'specify item values', where the values are, by default, the numbers, and the text is something I've specified in the tab field under "Items in the list." What is the syntax for the use of these numerical values instead of text? Here's what I tried without success.
If xfa.resolvNode(form1.#subform[0].typeOfIncidentDdl).value = "1"; {
[fields become visible and required with error messages]
} else {}
[fields are hidden and not required]
}And this:
var oSubform = xfa.resolveNode("form1.#subform[0].typeOfIncidentDdl.Value");
If (oSubform = 1); {etc.
And this:
var oSubform = xfa.resolveNode("form1.#subform[0].typeOfIncidentDdl.rawValue");
If (oSubform = 1); {etc.
I need to be close, but I don't quite have the correct syntax. Thank you for pointing me in the right direction.
Hello
Good man Jono, I cracked switch statements based on his examples
I suspect that this is part of the reverse lookup that explained Paul.
My understanding (now):
- xfa.event.newText is the new value, but it is not yet fully committed to the value of the drop-down list.
- With the help of this.boundItem (xfa.event.newText); you use this newly modified (but not yet posted) value and it controls against known display items.
- The switch statement then uses this display element, rather than the uncommitted newText.
I still think I have uses the event exit and rawValue, but "if it ain't broke, don't fix it!"
Good luck
Niall
-
Popup is not refreshing based on the current value of the row in a table
Hi all
1.I have created an entity object View for the Table Emp
2. then I created an editable view object based on the EMP table
3. create a Page like jspx
4 drag and drop the View object as read-only Table in this homepage
5 drag and drop the view even object as in this homepage
6 goto the shape and dressing with Popup
7. then create a dialog inside the pop-up window
8. then, go to the Table and then surround with a collection of panels
9. create a button in the toolbar of the collection Panel name it as edit
10. drag and drop the showpopupbehaviour the button change
When I run the application. It displays all records in the emp table. If I'm in line 6. It shows the values of line 6 in the pop-up window, but if I moved to the next line which is the 7th and then press the button to change is to always show the 6th place of the values only.how to display the values in the pop-up window based on the cursor line .pls guide me in this.
Thanks in advance
C.KarukkuvelHello
Make sure you use contentDelivery = "lazyUncached" in the context menu
Gabriel
-
Passing DB values to the text based on the Select Value box
Hello
I'm very big thing back to the Oracle APEX. In my project, I have a requirement in which I need to pass different values for the corresponding text boxes on a different page based on the value I select in the item "Select Value".
I tried using processes calling for demand, but could not get the desired result.
Please suggest!Hello
Can you repeat your scenario on apex.oracle.com? It will be easier to fix it this way.
Kind regards
-
Offshoot of page based on the return value of function
I have a combo box (P2008_SUPPORTING_MATERIALS) with 'Yes' and 'No' values.
I need a button that will save the selected value, and then create a branch to the 1092 page if it of 'Yes' or branch to page 2094 if it is 'no '.
That's what I did:
1 create a SAVE button
2. created a page process of type PL/SQL with function (see code below) inside (PageBranchDecision). The conditional processing I put him "when press button" for the "SAVE" button.
3. create a branch of the page with a branch type of DIRECTION to the FUNCTION RETURN A PAGE. For the action of the branch, I put the name of the procedure on the page (PageBranchDecision). Because these are conditions, I defined him "when press button" on the "SAVE" button.
This is the code for the page process:
DECLARE
whole n_page_id;
v_sup VARCHAR2 (3);
BEGIN
v_sup: =: P2008_SUPPORTING_MATERIALS;
IF v_sup = "Yes".
THEN
SELECT 1092 INTO double n_page_id;
RETURN n_page_id;
ON THE OTHER
SELECT 2049 INTO double n_page_id;
RETURN n_page_id;
END if;
END;
Now, that's the problem... According to the 'Oracle HTML DB manual"page 294 books and ' easy Oracle HTML-DB' page 307, with the type of the branch of 'Branch to function returning a Page', a function PL/SQL is written which returns a digital page at junction id. In my code, it would be 'n_page_id '. But, when I run my page and click on my "SAVE" button I gives me an error that a RETURN statement cannot contain an expression.
I don't know why I get this error. I need to get the value of the page to the branch based on the 'yes' or 'no '.
Someone has an idea what I am doing wrong? My situation seems, as it is possible through the logic, I'm following?
Thanks in advance,
Maggiech - ensure that any unconditional branch on the page has a largest number in sequence to ensure that this branch is triggered and ensure that there is no other branch that is triggered by the "SAVE" button
Maybe you are looking for
-
WordPress blog editor cannot see the icons...
Hello I'm not too computer savvy, but since I updated Firefox, I can't see the icons on my Wordpress blog. I can see them in Internet Explorer.I tried clear all the cache and cookies... Hope you can shed some light on my problem. I thank in advanceBu
-
Y at - it another video card that could improve the sharpness of my LED Cinema Display Monitor. I currently have the following system configuration: Presentation of the material: Model name: Mac Pro Model identifier: MacPro5, 1 Processor name: 6-Core
-
Satellite A100 - looking for a BIOS update
I have the problem of my laptop: the screen goes black and the pc restarts Suggest you solution and problem BIOS update reports on the technical page of toshiba supprt. When I get my satellite A100-036 give me the error page not found the page you re
-
Dear friends, Anyone can read the attached file (. txt) with LabVIEW? MATLAB does Thank you
-
Error loading \3\DLBUtime.dll I have a Dell computer that came with Windows XP Home edition. When I start my computer the monitoring of ERROR appears: RUNDLL error loading specified not found \3\DLBUtime.dll module I just click 'ok' and he goes, but