Exchange of values in a column
have a column that has the first / last names. problem is that it is a free form text field. Please put in different ways.I need to take all the values that have a comma... take the name after the comma and put it in the beginning.also then need to remove the comma.
create table test_names (
name varchar2(100)
)
insert into test_names (name) values ('JONES, BOB');
insert into test_names (name) values ('JOHNSON,MIKE');
insert into test_names (name) values ('SMITH, MARY ANN');
insert into test_names (name) values ('PIERRI-CARLSON, CHRISTEN');
insert into test_names (name) values ('SUZY SMITHSON');
insert into test_names (name) values ('MARK SANTOSH');
-select name from test_names-result
JONES, BOB
JOHNSON, MIKE
SMITH, MARY ANN
PIERRI-CARLSON, CHRISTEN
need to look like
BOB JONES
MIKE JOHNSON
MARY ANN SMITH
CHRISTEN PIERRI-CARLSON
SUZY SMITHSON
SANTOSH MARK
It is but im so far... but do not know if this is the best way to do it. Also do not know how to swap names.
select name from test_names where name not like '%,%'
union
select replace(name, ',',' ') from (
select name from test_names where name like '%,%')
Thanks for any help
Perhaps (as no version specified) NO TESTS!
select case when instr(name,',') > 0
then ltrim(substr(name,instr(name,',')),', ') || ' ' || substr(name,1,instr(name,',') - 1)
else name
end name
from test_names
Concerning
Etbin
Tags: Database
Similar Questions
-
Exchange of values between two columns
I have a MEMBERS_SYSTEMS_ID table with three columns ID, B1, B2.
I need to swap values between B1 and B2 for particular values of ID.
IAM trying the following but is not working, please help solve + [If you can also tell why my SQL does not work which would be awesome] +.
BEGIN
DECLARE the temp varchar (50)
UPDATE MEMBERS. MEMBERS_SYSTEMS_ID
SET temp = B2,
B2 = B1,
B1 = temp
WHERE ID IN ('85 ', ' 86');
ENDYou cannot update a variable as part of an update, only columns in the table. And, in fact, you don't have an intermediate variable, just do the update directly as:
SQL> SELECT * FROM t; ID DESCR1 DESCR2 ---------- ---------- ---------- 1 Descr2 Descr1 1 Other2 Other2 2 Two1 Two2 SQL> UPDATE t 2 SET descr1 = Descr2, 3 descr2 = descr1 4 WHERE id = 1; 2 rows updated. SQL> SELECT * FROM t; ID DESCR1 DESCR2 ---------- ---------- ---------- 1 Descr1 Descr2 1 Other2 Other2 2 Two1 Two2
John
-
How to highlight the minimum value in a column?
I need to highlight the lowest value in each column in my spreadsheet. I try to use the conditional nail, but I can't find a function to work as I need.
One way would be to calculate the minutes in a cell of a footer row, select the cells in the body of the column and apply conditional highlighting like this:
You must click on the chip address first, and then select the comparison cell, A8 here, then be sure to keep the row and column.
The A8 from the example formula is = MIN (A).
The result is a bold 2 (not shown in the screenshots).
SG
-
I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?
Add two new columns after than the original with space separated values column.
Select cell B1 and type (or copy and paste it here) the formula:
= IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')
shortcut for this is:
B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')
C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")
or
the formula of the C1 could also be:
= IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")
Select cells B1 and C1, copy
Select cells B1 at the end of the C column, paste
-
How to calculate the sum of the values of some columns in a table
Hello
I want to get the column just the average of the values of some columns not all columns of the table.what I have to change exactly in this block diagram.even if the table size is 25 average, I want the division as the number of values in each column (= number of lines)
just like that:
-
Max and Min value for each column
Hello!
Can someone help me to change my. VI? I want to get the Min and Max value for each column in the table in the appendices. Then I need to create two tables 1 d - the first with the min and the second with the max value.
I've already solved the problem the solution is below
-
find the average of each 500 values in a column [text file]
Please help, I have a text file with three columns of integer values of hv. I need to take 500 values in each column and replace them with their average.
A particular work if it could probably be simplified. Here are a few ideas... Many things could be improved even more.
-
How to get the value of a column in sql query?
Hi, anyone knows how to get the value of a column in sql query?
Here is my code, the value must be 1350079224397 in my PB, but I get 0
QString query ("SELECT version FROM db_version");
QVariant result = sda.execute (query);
QVariantMap versionMap = result.toList () such () .toMap ();
If (! versionMap.IsEmpty ())
{
qDebug()<"Version: "="">"Version:><>
}OK, I have the solution
QString query ("SELECT version as version FROM db_version");
-
Query, which returns lines adding up to a value in a column
Hello
You are looking for an application that will process and return only the many lines that add up to a special value on a column value.
for example
ID name date_joined allocated salary
-- ------ --------------- ------- ------------
1 Tom January 1, 2010 1000 5000
Dave 2 3000 5000 February 1, 2010
3 Cindy 1000 5000 01-apr-2010
4 Ian 01-mar-2010 1000 5000
5 Matt 10 -jan-2010 1000-5000
Return the lines where wages adding upto or beyond the value allocated to 5000, order by date_joined or more former employee first.
The query should return:
ID name date_joined allocated salary
-- ------ --------------- ------- ------------
1 Tom January 1, 2010 1000 5000
2 Matt 10 -jan-2010 1000-5000
3 Ian 01-mar-2010 1000 5000
Dave 4 3000 5000 February 1, 2010
We do not want to deal with or include other lines summarizing calculation, would instead add first, if deficit adds to the line.
Tried with lead, windowed with range UNLIMITED etc. that PRECEDES, that would not come up with good logic.
I could make it work with PL/SQL, but do it in SQL turns out to be delicate.
Thank you.
A.
Thanks for the input guys.
Here, the ask is:
1. how to treat only as lines that satisfy the "allocated" value, without treatment of all lines.
> Thanks to Jarkko year John for the right direction.
> RanitB thank you for your approach to the application of the model, I am not well versed with model query that I'll get to. But for the moment its not useful for me.
2. to get only as much lines that are either less than or equal to 'assigned' value or satisfy "allocated", from less than "attributed" just beyond "allocated".
(Sorry for the language, if its not very clear, I do not know how this fits better, following example should help demonstrate).
I came up with the following code, although there could be best way to do it, I hope to see someone.
{code: sql}
create table t:
Select object_name, join_dt, the salary of 1000 last_ddl_time, allocated 5500
of object;
Select
/ * gather_plan_statistics * / *.
Of
(select
object_name, join_dt, salary, allocated, sofar, lag (sofar, 1, 0) over (order by join_dt) lag_sofar
Of
(select
object_name, join_dt, salary, allocated,
Salary on sofar (order by no_lig)
Of
(select object_name, join_dt, salary, allocated, row_number() on no_lig (order of join_dt) t) t - must do it has several join_dt even inputs (objects have same time ddl)
)
)
where
allocated > lag_sofar;
OBJECT_NAME JOIN_DT SALARY ALLOCATED SOFAR LAG_SOFAR SDO_TOPO_GEOMETRY 17 JULY 02 1000
5500 1000 0 SI_AVERAGECOLOR 18 JULY 02 1000 5500 2000 1000 SI_COLORHISTOGRAM 18 JULY 02 1000 5500 3000 2000 SI_POSITIONALCOLOR 18 JULY 02 1000 5500 4000 3000 SI_FEATURELIST 18 JULY 02 1000 5500 5000 4000 SI_STILLIMAGE 18 JULY 02 1000 5500 6000 5000 {code}
Sorry for the bad formatting, I tried couple of code integration/formatting of tags, but could not get formatting just as many of you have done above.
Can someone point me on the document where the tags for this type of formatting is present?
For now I am marking my question as answered with my own response and that of the other answers as useful.
If I get a better approach/solution I would mark it as correct.
-
value of the column in my data base
Hi Master,
I'm running the query to find the value of a column in my diagram below. But when I change user_tab_columns in all_tab_columns, I get the error message.
I use 11.2.0.1 Oracle version. without the help of xml, we can get the desired result? Please help me.
Select table_name, column_name
(select rownum, table_name, column_name,
dbms_xmlgen. GetXml ('select 1 from "'|") table_name | " » où « ' || column_name |' ("=" & val "') x
from all_tab_columns where data_type = "VARCHAR2".
) where length (x)! = 0 ;
ORA-19202: an error has occurred in the processing of XML
ORA-00942: table or view does not exist
ORA-06512: at "SYS." DBMS_XMLGEN", line 176
ORA-06512: at line 1.
How to avoid this error? and how do I get the power requested by the query above? Please notify.
Concerning
AR
Unable to reproduce this scenario, give it a try with this and check if works...
SELECT owner, table_name, column_name FROM (SELECT ROWNUM, owner, table_name, column_name, CONVERT ( DBMS_XMLGEN.getxml ( 'select 1 from "' || owner || '"."' || table_name || '" where "' || column_name || '" =''&val'''), 'UTF8', 'WE8MSWIN1252') AS x FROM all_tab_columns WHERE data_type = 'VARCHAR2' AND owner ='SCOTT') WHERE LENGTH (X) != 0;
See you soon,.
Manik.
-
Using the value of the column of the report in view state
Hi all
I have a little trouble as long as you report column. Here's the problem I have face.
I have a classic report in apex5 (universal theme). Please find the page here https://apex.oracle.com/pls/apex/f?p=62495:5:
I want to have a condition that SAL column should appear only if DEPTNO! = 10. For this, I put a conditional display for SAL column that "point value / expression 1 column! Expression 2 ="and #DEPTNO # expression1 and expression2 10. But this doesn't seem to work. Can someone help me understand the issue.
Note: I want to view only the column of the report, not the page item in the condition.
Thank you
Stephanie.
Kalesh Ravi-Oracle wrote:
I want to have a condition that SAL column should appear only if DEPTNO! = 10. For this, I put a conditional display for SAL column that "point value / expression 1 column! Expression 2 ="and #DEPTNO # expression1 and expression2 10. But this doesn't seem to work. Can someone help me understand the issue.
It is not possible to report baseline values in the State of the reference column. It would be unwise to do so: how APEX can determine if the column should be included or not until all rows are retrieved?
Note: I want to view only the column of the report, not the page item in the condition.
Why? In the example given, this is the correct (and more effective) approach. If the condition must be based on the expected query results, then use a Exists (SQL query returns at least one row) or NOT Exists (SQL query returns no line) condition.
-
Hi Experts ADF,
JDev 12 c.
I create a button and a table below. If the user clicks on the button create, I invoke CreateInsert. The new line now appears as an editable fields.
So I suppose I have a column that is displayed in editable mode. If the user enters values in that. Has another column B whose value is not displayed in the UI must have the same value as the column.
This occurs for each row added. During the click on save if user entered 2 in column A, then the value in column B must be same 2.
Thank you
Roy
There is more than one way, for example:
Generate ViewRowImpl Java class (with generate audited accessors) you will get for an attribute setter.
Change the Set accessor to set the attribute B (IE, calling setAttribute ("B", value)) after setting a value
OR, write valueChangeListener for inputText representative and set the B attribute to the same value
-
need to update the value of the column automatically (exists and the new value)
Hello
(1) I Segment1, Segment2, Segment3, Segment4, item_status (new column modified in the Temp table)
Must update the form OFA and the DB Temp table item_status value in the column when I click APPLY to SAVE the Inserted records in the DB table and form and must register the mtl_system_items_b Segment1, Segment2, Segment3, Segment4 in which the condition
Note: need to update automatically item_status for existing and new inserted records in the Table and the form
Serializable[] param = {Segment1, Segment2, Segment3, Segment4 }; am.invokeMethod("InsertRecord", param); row.setAttribute("SelectFlag", "N");
Thank you
Renon,
When you write code, try to understand what makes each line. (If you don't understand all the lines, feel free to ask)
row.setAttribute ("ItemStatus", row.getAttribute ("ItemStatus"));
What do you think that the above line done? You try to get the value of the attribute and trying to put the same value. How is it, that will have an impact?
You need to do 2 things.
1. change the insertRecord method and the State of return of this method.
Change the definition of the function:
public String InsertRecord (String itemstyle, String itemcust, String itemsize, String itemcolor, String ordrno,
String desc)
Add a return statement at the end after validation.
TR.Commit ();
return the situation;
}
2 accept that status in CO and set the value to the attribute details VO.
String status = (String)am.invokeMethod ("InsertRecord", param);
row.setAttribute ("ItemStatus",status);
I hope this helps.
See you soon
AJ
-
How to use the values in the columns of an interactive report (Apex 5)
Hello
I have an interactive report and a link column and I click to set the value of four fields in a subregion with the value of four columns of the report.
This without submitting the page every time so I think using javascript.
But what is the right way to do this in 5 Apex?
How to have a reference to the column of a report (customer.name to the customer or customer.city, for example)?
Concerning
Gianpaolo
Hi gianpagi,
gianpagi wrote:
I can't run your code as well, on apex.oracle.com, I have re-product the situation with the emp table and the columns ename, sal and the fields p1_ename, p1_job, p1_sal
Can you help me.
https://Apex.Oracle.com/pls/Apex/f?p=4550:1:103040501310506:
https://Apex.Oracle.com/pls/Apex/f?p=102726:LOGIN_DESKTOP:104044067688962:
user and developer demo/demo (TR1 workspace)
Check the application now. I've done the column 'Empno' as link and execution of your dynamic action on click on the link.
Here are the changes:
- Edited the "Empno" column attributes and perform the following settings in the properties of 'column link:
Text link: #EMPNO #.
Link attributes: class = 'empdetails '.
Target: URL
URL: javascript:void (0);
NOTE: The link does nothing but on the onclick for the event of link DA no real logic.
- Edited the dynamic action 'assign values' and set the following properties:
Selection type: jQuery Selector
jQuery Selector: a.empdetails
Kind regards
Kiran
-
update the value of the column to the next value
Hi all
create table xxc_test (date of from_date, to_date date, amount, number incr_amount);
Select 2014, 2015, 3000, the double null
If suppose if input data in the incr_amount then let say 1000 I want to update the value with incr_amount column amount
Select 2014, 2015, 4,000 of the double
If not even though it is as
Select 2014, 2015, 3000, the double null
and must be updated to the year
Note: I spend the year, amount,incr_amount manually (run-time)
Post edited by: Rajesh123 Note added in the subect
Hello
: new.incr_amount: = 0; also use it in code.
The condition " If : new.incr_amoun is > 0" then (sure fire or change the value only if the increment is positive. ).
,....
..
end if;
-Thank you
Pavan Kumar N
Maybe you are looking for
-
Export bookmarks does not work for me.
I tried to export my bookmarks to a file html several times now. The bookmarks.html file appears anywhere on my computer (I have searched for it). I know I've done this before (for more than one year) on previous versions of firefox, but it does not
-
I have a late 2009 iMac. When I tried to upgrade to El Capitan. He said that the CHIP shows the h/d is a failure and can not be updated. I have install an external withEl of h/d Cap but it is very slow. the h/d is USB 3 but the iMac's USB 2. the h/d
-
HP Compaq: New question recovery files
You have been helpful with my previous questions, maybe someone can help me with this. I recently convinced me to convert Windows 8 for Windows of 10, in many ways, but has problems. Another quite serious is that a lot of my files have been created
-
How to download pictures from an iPhone to Adobe Bridge now, I upgraded to El Capitan?
How to download pictures from an iPhone to Adobe Bridge now, I upgraded to El Capitan?
-
Aspect wide photo after you transfer the images from the camera
Original title - aspect wide photo after download After you transfer the pictures from my camera to my PC, subjects are not as the original photo taken. People who are really thin show also stubby. I used another PC and downloaded normally photos.