replace text or value in same column in oracle sql - sql

how to replace value or text in same column in oracle sql?
If I add rows in column actual_year for plant 1234, it is equal to value in the row for plant 1235. Similarly if I add rows in column actual_year for plant 9876, it is equal to value in the row for plant 5432. Now, I want to replace plant 1234 by 1235 and 9876 by 5432. There are many cases like these in my table. Apologies for adding image instead of a table. But I dont know how to add a table here.

Related

SQL: Update values in column based on another

I have an SQL table, 1 column has stuff written in this way 'AAAA-BB-CC', and the second one has values written in the following format 'XXXX YYYYYY'
How can I make a SQL query that would make the 2nd column 'AAAA-BB-CC YYYYYY'. Basically I want to take the value in column 1 + the 2nd part of the value in column 2 and update column 2 to have this new value

insert and update from table a to table b by combining 2 column from table a in postgres

I have 2 tables name Table A and Table B
"Table A has 10 columns named ta1, ta2, ta3...ta10"
"Table b has 2 columns name id (PK,AI) and tb1"
My requirement is to combine "ta3" and "ta4" from table A initially,
or it will check for the "tb1" column whether any same data is available, if available do nothing else insert the new data.(if a new row is added in the ta3 or ta4, it should be added to the 2nd table column named tb1)
I have checked other functions in the for combining the data from ta3 and ta4 by using the "unnest" function, but if I use that, I'm getting stuck in the insert, as it will insert on each query rather than checking whether any data is there or not.
any solution on this legends.
simply I just want to combine 2 column from 1st table and store it in a column on 2nd table, but in 2nd table's column it should be only distinct values taken from both of those 1st table columns. this should automatically check for the values in the column of 2nd table and compare that with the new one and if there is change the insert else neglect. I hope my question is clear.
Table1
Table 2
new table-1
Expected table-2

Replacing values in a table with a value from another table (complicated)

I have a table that contains various values in a single cell. I want to replace part of the value in that cell that matches with a value from another table.
Researched extensively online but could not find a lot of information regarding it.
For example - I have the following table
If part of the value in table 1 matches with table 2, I want it to be replaced with the value from table 2 (second column).
For example in table 1 - value "www.portal.com/kav1232" matches with "www.portal.com/kav1232" in table 2 then the value in the cell from table 1 is replaced with "www.new1.com" but rest of the content from the cell remains the same.

SSRS - Parameter based on reference table

I have multiple datasets with the WHERE clause = #customernumber.
I have a customer number data set that contains a field with a unique id and a field that contains multiple ids.
I.e.
Customer Number | Old Customer Numbers
123 123
123 34324
123 4363
123 124214
345 345
345 436346
345 234532
678 678
I want to be able to search in the parameter box for the old customer number but use the customer number in querying my datasets.
My datasets only contain the customer number, not the old customer numbers.
While creating the parameter you can select the value and the label of the dropdown list.
In the Available Values tab select Get values from a query, for dataset just choose the dataset that query the table with new and old codes. In Value field select the new code and in the Label field select the old code.
UPDATE:
Create a parameter called OldCode. Set the data type to text or integer based on old customer code number. Don't use default or available values for this parameter.
Create a dataset that use the #OldCode parameter to return the customer number. Use something like this:
select
Customer_Number
from CustomerTable
where Old_Customer_Number = #OldCode
Create a parameter called CustomerNumber. Set Hidden property and select the data type based on the Customer_Number column. In Default Values tab select the dataset created previously and the Customer_Number column as Value field.
After that you can use #CustomerNumber in all your datasets. When user input a old code the #CustomerNumber will be populated with the related Customer_Number value.
Let me know if this helps.

Access - Check if a value exists in another table after insert

I have a table with the field "Name" among the others. When I insert a new value in that field, I need a check to see if it exists in another table (same field, "Name"), and if it doesn't, I need that it creates a new row in this table with the value inserted
Example:
First Table Second Table
Name Cost Name Cost
John 1000€ John 1200€
John 200€ James 2000€
James 2000€
If I try to insert, for example, "Mark" in the first table, since it isn't in the second table, it adds a new row in the second, so the result is
Second Table
Name Cost
John 1200€
James 2000€
Mark 0€
The check is on the field "name"
Here is the actual database, but it is in italian. The Form "Commesse" has the button "aggiungi cliente" where I write a new name and then save it with "Salva cliente". I need that the other three tables and relative forms to have updated the "Nome_Cliente" field.
This is easy to do with an After Insert data macro on the first table:
For more information on data macros, see:
Create a data macro