Divided into a single column
Hello
I need to split into single column in the format below:
SELECT '6500,1100,3200,1233,9000' FROM DUAL;
Result:
6500
1100
3200
1233
9000
For 11g and above:
Select regexp_substr (6500, 1100, 3200, 1233, 9000', ' [^,] +', 1, level) suite
of the double
connect by level<= regexp_count('6500,1100,3200,1233,9000',="" ',')="" +="">=>
For 10g:
Select regexp_substr (6500, 1100, 3200, 1233, 9000', ' [^,] +', 1, level) suite
of the double
connect by level<= length="" (regexp_replace="" ('6500,1100,3200,1233,9000',="" '[^,]+'))="" +="">=>
or (if there is no empty entries):
Select regexp_substr (6500, 1100, 3200, 1233, 9000', ' [^,] +', 1, level) suite
of the double
connect regexp_substr (6500, 1100, 3200, 1233, 9000', ' [^,] +', 1, level) is not null
RESULT |
---|
6500 |
1100 |
3200 |
1233 |
9000 |
5 selected lines.
Tags: Database
Similar Questions
-
Merge multiple columns into a single column?
Hello
I need to perform queries dynamically and the return values. I need to retrieve the values of the queries in a single column only by concatenating multiple columns. I can't use the PL/SQL in my scenario.
is it possible to run a query and the result will be extracted in a single column (multiple column values must be concatenated)?
Thank you
Raja.SELECT rtrim(extract(xmltype(REPLACE(column_value,''',',')),'/ROW/*/text()'),',') col FROM TABLE (SELECT xmlsequence(dbms_xmlgen.getxmltype('select * from employees').extract('ROWSET/ROW')) FROM dual );
Check this box... Copy it directly to this
Ravi Kumar
-
inserting rows into a single column million
I saw 494020 table rows, and then I added a sr_no column, I want to insert the the number of (1 to 494020) in this column can tell everything. ?
How can insert using rownum.
UPDATE my_table SET column1 = ROWNUM;
-
subtract, divide into a single custom script calc
I am very new to all this and have created a custom with the help of this community script. I try to get the percentage increase, when a person gets a pay rise...
My fields are Pay1 = old rate, funds2 = new rate, payer3 = amount of increase and Pay4 percentage increase.
I have the script below in the Pay4 fields:
var P1 = Number (this.getField("Pay1").value);
var P2 = Number (this.getField("Pay2").value);
If (P1 = 0) {P1 = 1}
If (P2 = 0) {P2 = 1}
var P3R = P1/P2 * 100;
var PERC3NT = 100 - P3R;
PERC3NT = PERC3NT / 100;
this.getField("Pay4").value = PERC3NT;
I noticed that if I replace "funds2' with 'Payer3' I get a smaller amount as the percentage. I know I need to divide the difference of the old rate increased and the time by 100 to get the percentage. I seem to be missing something because even when I change the rate to a dollar more my percentage does not seem fair. Can help you.
This is because you need to divide the new salary of old, not the other way around.
I think that this code should work fine:
var P1 = Number (this.getField("Pay1").value);
var P2 = Number (this.getField("Pay2").value);
If (P1 == 0 |) P2 == 0) {event.value = ""}
else event.value = ((P2/P1)-1) * 100;
-
Select multiple columns into a single column group
SQL dear Experts,
I have a question related to pl/sql.
I do query below. Please advice in right way.
Select phone, firstname, lastname code
of the customer
Code group
Group, but in the meantime, firstname and lastname.
Please advice
Thank you
AngeliqueBilly wrote:
I have a question related to pl/sql.
You posted the SQL code. Not PL/SQL code.
I do query below. Please advice in right way.
Select phone, firstname, lastname code
of the customer
Code groupGroup, but in the meantime, firstname and lastname.
Of course, you will also need to group by firstname and lastname for this SQL query.
With a Group of SQL, you have basically 2 types of values that can be returned:
-the value of Group of
-l' aggregated/calculated the value of this groupIf you could watch the first name and the last name by code:
select code, MIN(firstname), MAX(lastname) from customer group by code
You can see the number of unique name and surname by code:
select code, COUNT(DISTINCT firstname), COUNT(DISTINCT lastname) from customer group by code
Think of the clause group by in size (for example the code in the SQL above) and measures (calculations by code in the SQL above).
-
Convert the lines into a single column
create table suresh
(
Identification number,
ch char (1)
)
;
Insert in suresh values(1,'i');
Insert in suresh values(1,'a');
Insert in suresh values(1,'m');
Insert in suresh values(1,'b');
Insert in suresh values(1,'o');
Insert in suresh values(1,'y');
Select * from suresh
ID ch
1 I
1 a
1 m
1 b
1 o
1 y
I'm looking for output something like this
ID ch
1 iamboy
..select id,listagg(ch) within group(order by ch) as ch from suresh group by id
-
Divide the values of a single column into multiple values of columns
I want that the values of the "col_val" column to divide into several values in the column
Table1:
Col_val Col1, Col2
Code1 POINT 45
L2 AB 45
L1 POINT 45 OF
Code2 CAB 61
ABC 51 LABORATORY
SSS LAB 45
QQQ BED 123
BBV COT 100
FFF COT 444
Output as expected:
OUT1 out2 out3-out4, out5
Code1 AB SSS
L1
Code2
ABC
QQQ
BBV
FFF
Each line must contain the values corresponding to the Col2 values and each column must have the values in Col1, as illustrated above.
SQL> with t 2 as 3 ( 4 select 'Code1' col_val, 'ITEM' col1, 45 col2 5 from dual 6 union all 7 select 'L2' col_val, 'AB' col1, 45 col2 8 from dual 9 union all 10 select 'L1' col_val, 'ITEM' col1, 45 col2 11 from dual 12 union all 13 select 'Code2' col_val, 'CAB' col1, 61 col2 14 from dual 15 union all 16 select 'ABC' col_val, 'LAB' col1, 51 col2 17 from dual 18 union all 19 select 'SSS' col_val, 'LAB' col1, 45 col2 20 from dual 21 union all 22 select 'QQQ' col_val, 'COT' col1, 123 col2 23 from dual 24 union all 25 select 'BBV' col_val, 'COT' col1, 100 col2 26 from dual 27 union all 28 select 'FFF' col_val, 'COT' col1, 444 col2 29 from dual 30 ) 31 select max(col1) 32 , max(col2) 33 , max(col3) 34 , max(col4) 35 , max(col5) 36 from ( 37 select decode(col1, 'ITEM', col_val) col1 38 , decode(col1, 'AB' , col_val) col2 39 , decode(col1, 'LAB' , col_val) col3 40 , decode(col1, 'CAB' , col_val) col4 41 , decode(col1, 'COT' , col_val) col5 42 , t.col2 col_2 43 , row_number() over(partition by col2, col1 order by 1) rno 44 from t 45 ) 46 group 47 by col_2, rno 48 order 49 by col_2; MAX(C MAX(C MAX(C MAX(C MAX(C ----- ----- ----- ----- ----- Code1 L2 SSS L1 ABC Code2 BBV QQQ FFF 7 rows selected. SQL>
-
Convert a single column into multiple lines
Hi people,
I have a task to display a single column into multiple lines (for use in LOV)
For Ex:
The column consistes of value such as 98,78,67,68,34,90. -It's a unique column values where none of the values can be ' number that is separated by commas
Then we must view it as
98
78
67
68
34
90
-under the number of lines (no lines can be ' do not number).
Thanks in advanceTry this...
SQL> ed Wrote file afiedt.buf 1 select regexp_substr('98,78,67,68,34,90', '[^,]+',1,level) Value 2 from dual 3* connect by level <= regexp_count('98,78,67,68,34,90',',') + 1 SQL> / VALUE ----------------- 98 78 67 68 34 90 6 rows selected.
Thank you!
-
concatenate the strings from a column into a single row?
How to concatenate strings from a column into a single line?
Color
------
Red
Orange
Blue
Green
And return a set of results as follows:
Colors
-------------------------
Red, orange, blue, greenVarious ways can be found here:
http://www.Oracle-base.com/articles/10G/StringAggregationTechniques.php -
Two foreign keys of a table in a single column
Hi gurus
I wonder that can we add two foreign keys of a table on a single column, I think the answer is, but what should be the reason behind this?
Appreciate if someone there explain to me...
Concerning
Muzz
Hello Muzz,
Perhaps the example of human Chen reveals a design error.
If a student has a 'teacher_id' "teacher" FK and FK for "emp" becaue each teacher is an EMP, I guess that the correct design would be to have only the FK of 'teacher' and to have another pointing to the 'emp' table in the 'teacher' tabe FKBut we can imagine comical situations...
CREATE TABLE PEOPLE (id NUMBER of KEY PRIMARY, name VARCHAR2 (20 CHAR),...);
CREATE TABLE SCIENTIST (id people KEY PRIMARY NUMBER (id) REFERENCES, discipline VARCHAR2 (20 CHAR),...);
CREATE TABLE POLICEMAN (id REFERENCES to KEY PRIMARY NUMBER (id), hire_date people DATE,...);First table = all.
2nd: a subset of the first, with people having the profile of 'scientific '...
3rd: a subset of the first, with people being a policeman.
It might be people first table and in none of the 2nd and 3rd, 1st and 2nd, 1st and 3rd only or in the 3 tables.Then we can have a fourth table of 'something' referring to a person who must be a scientist and a police officer.
Here is a sqlplus session illustrating; the last piece: I try inserting several lines in xxxx, only the last is accepted.
SQL > CREATE TABLE PEOPLE (id NUMBER of the PRIMARY KEY, name VARCHAR2 (20 CHAR));
Table created.SQL > CREATE TABLE SCIENTIST (people of REFERENCES of KEY PRIMARY NUMBER id (id), discipline VARCHAR2 (20 CHAR));
Table created.SQL > CREATE TABLE POLICEMAN (people of REFERENCES of KEY PRIMARY NUMBER id (id), DATE hire_date);
Table created.SQL > CREATE TABLE XXXX (id PRIMARY KEY NUMBER, people_id NUMBER, any other VARCHAR2 (30 CHAR));
Table created.SQL > ALTER TABLE ADD CONSTRAiNT fk_xxsci FOREIGN KEY (people_id) scientific xxxx REFERENCES (id);
Modified table.SQL > ALTER TABLE ADD CONSTRAiNT fk_xxpol FOREIGN KEY (people_id) police xxxx REFERENCES (id);
Modified table.SQL > INSERT INTO person VALUES (100, 'John');
1 line of creation.SQL > INSERT INTO person VALUES (120, 'Mary');
1 line of creation.SQL > INSERT INTO person VALUES (103, 'Tom');
1 line of creation.SQL > INSERT INTO person VALUES (123, "Bruno");
1 line of creation.SQL > INSERT INTO VALUES of scientific (120, 'Chemistry');
1 line of creation.SQL > INSERT INTO scientific VALUES (123, 'Mathematics');
1 line of creation.SQL > INSERT INTO VALUES of policeman (103, DATE ' 2001-04-01');
1 line of creation.SQL > INSERT INTO VALUES of policeman (123, DATE ' 1998-07-01');
1 line of creation.SQL > INSERT INTO xxxx VALUES (1, 456, "nothing");
ERROR on line 1:
ORA-02291: integrity constraint (SYS. FK_XXPOL) violated - key parent not foundSQL > INSERT INTO xxxx VALUES (1, 100, "only to people");
ORA-02291: integrity constraint (SYS. FK_XXPOL) violated - key parent not foundSQL > INSERT INTO xxxx VALUES (1, 120, "only the learned");
ORA-02291: integrity constraint (SYS. FK_XXPOL) violated - key parent not foundSQL > INSERT INTO xxxx VALUES (1, 103, "only police officer");
ORA-02291: integrity constraint (SYS. FK_XXSCI) violated - key parent not foundSQL > INSERT INTO xxxx VALUES (1, 123, 'ok');
1 line of creation.Best regards
Bruno Vroman.
-
Selection of Pixel single column, then paste...
Hello
This might look like a very unusual request, but I was upset to find the answer.
In a given photographic image, I would choose a single pixel in each row of pixels, running up and down in a columnof a pixel. Then, I want to eliminate (Cup) nothing else on the Web with the exception of the one column of selected pixels. From there, I would take the pixel selected in each line and copy the pixel color on each line on the left and right of the pixel selected.
The end result is that I have a series of horizontal lines of pixels height of one color (based on the color of the selected pixel) through the image of left and right.
Looking at this picture:
Select a single pixel on each line in a single column-
xxxxxx XXXXXXS
xxxxxx XXXXXXS
xxxxxx XXXXXXS
Remove/cut everything except the selected pixels in only one column-
...... S......
...... S......
...... S......
Now, on each line, copy single pixel selected to the left and the right of the selection, to the extent of the canvas-
SCOTTS SCOTT
SCOTTS SCOTT
SCOTTS SCOTT
Interesting challenge or Easy-Peasey?
Thank you!
Easy. Use the brand single pixel tool to select a line of pixels. Cmd/Ctrl-J to copy pixels into a new layer. CTRL/cmd-click on the layer icon to select these pixels. CTRL/cmd-T to turn those pixels on the width of the image.
-
Hi all
I have a requirement where I need to get all the records, for each record in double, I need to get a single column with null or 0.
create table a1
(
Identification number,
VARCHAR2 (100), the point
part varchar2 (100));
Insert into a1
values (1, 'ABC', 'A1');
Insert into a1
values (2, 'DEF', 'A2');
TABLE A
PART ITEM ID
1 ABC A1
1 ABC A1
1 ABC A1
DEF 2 A2
DEF 2 A2
3 DEF A2
O/P
PART ITEM ID
1 ABC A1
1 ABC 0
1 ABC 0
DEF 2 A2
2 DEF 0
3 DEF 0
Thanks in advance.
Thanks for your help FrankKalush...
This one will work.
WITH got_r_num AS
(
SELECT NVL (a1.id, a1.id) as id
NVL (a1.item, a1.item) AS element
NVL (a1.part, a1.part) IN the framework
a1.id AS a_id
ROW_NUMBER () OVER (PARTITION BY a1.id
ORDER BY NULL
) AS r_num
BY the a1
)
SELECT id
element
CASE
WHEN a_id IS NOT NULL
AND r_num = 1
THEN part
ELSE ' 0'
END in the framework
OF got_r_num
;
-
Need to the tab of each document (Word or PDF) being converted/combined into a single PDF file. Only have an online account. Is this possible online?
Hi pjj,.
When you open the Bookmarks pane (the second icon from the top in the column the leftmost in Acrobat), you will see a bookmark for each file that has been attached to create the PDF. If you have created the combined file from Acrobat.com, however, file names are changed, it won't be as easy to say what are the components. If you create the file in Acrobat, then bookmarks retain the name of the original file, so your customer will be able to tell at a glance if everything was included.
Best,
Sara
-
Object Table of XMLType vs single column of XMLType Table
What are the differences between the XMLType table object and a table with a single column of XMLType?
It's
CREATE TABLE XMLType xml_table;
and
CREATE TABLE xml_table (xml_field XMLTYPE);
That should be used and when? Both may be declared to be aware of schema.The main difference is that an XMLType object array allows the use of the XML DB Repository to store and retrieve XML content.
The relationship between a resource and its content is maintained by a "pointer" (REF XMLType) line in the XMLType table:http://docs.Oracle.com/CD/E11882_01/AppDev.112/e23094/xdb03usg.htm#ADXDB4223
http://docs.Oracle.com/CD/E11882_01/AppDev.112/e23094/xdb03usg.htm#BJFBDEJETables based on the patterns of XMLType (including the associated nested structure) can also be created automatically through recording scheme, which is very convenient when the pattern becomes complex.
In addition, a registred schema-compliant documents that go into the repository automatically stored in the table by default (see the annotation xdb:defaultTable).
We can also use ACLs to control access to specific rows in a table of object XMLType.This is not possible with XMLType columns in a relational table.
-
ORA-01461: can bind to a LONG value only for insert into a LONG column
Hello
Oracle XE on RHE dedicated server
Why do I get the error of subject?create table cvDetails( cd_id number(14) primary key, cv_id number(14) constraint education_fk references CvProperties(cv_id), nationality varchar2(230), objectives varchar2(3900), name varchar2(230), fatherName varchar2(230), motherName varchar2(230), dob varchar2(230), gender varchar2(230), mStatus varchar2(230), passportNo varchar2(110), email varchar2(230), phone varchar2(45), mobile varchar2(25), address varchar2(2500), state varchar2(230), zipCode varchar2(230), city varchar2(230), education clob, experience clob, skills clob, languages varchar2(1400), hobbies varchar2(3200), achievements varchar2(3900), references varchar2(3900) ); create sequence cvDetails_seq start with 1 increment by 1; create or replace trigger cvDetails_trig before insert on cvDetails referencing new as new for each row begin select cvDetails_seq.nextval into :new.cd_id from dual; end; /
Thank you in anticipation>
in any case, I checked manually according to your instructions and found that this objective column is of character input more than specified.
>
Glad you found the problem, but I hope that you learned a lesson that is time consuming.It must be remembered that we have no access to your environment. If we do not know which servers, clients, tables and users that you use.
It may seem simple to you but doesn't realize that you provide us with two slightly different versions of the cvDetails table.The original post had this
>
objectives varchar2 (3900).
>
But when you have provided your 'cvDetails desc' journal text has
>
OBJECTIVES VARCHAR2 (3950)
>
It is the same table that you started with how the column suddenly grow 50 bytes?
This means that you did from different parts of the present in the two schemas or on two servers or you change the table between the two.You can't address properly when you do this. By chance it is the column that you said is now the problem.
In SQL, the maximum length of a VARCHAR2 is 4000 bytes; no characters but bytes. Nothing more than 4000 bytes would probably be a LONG in the generic sense.If your error
>
Re: ORA-01461: can bind to a LONG value only for insert into a LONG column
>
means that you try to 'bind a LONG value' to a column VARCHAR2 and you can't you can 'bind a LONG value only for insert in a LONG column.In the proper context, the error makes sense.
You probably have a problem with
ps.setString(2, objectives);
because the 'objectives' has a length of more than 4000 bytes.
Remember this answer from you?
>
I have read and found that there may be a problem with the driver JDBC or Characterset. Am I wrong?
>
The 'Hello' ASCII string is five characters and five bytes because the ASCII code is a set of characters in a single byte. The same string internally in Java is five characters but ten bytes because Java uses UTF16.So, if the character set of the data itself is double-byte character set then anything more than 2000 characters (4000 bytes) is a "LONG". And if your column is defined as VARCHAR2 (3950), which means bytes a doublel-byte character set which are characters of 1975.
Then you said in a response later
>
I checked by the SNA Server and oracle that are both of the same but new thing I found is that oracle does not allow more than one clob column in a table. Is this true?
>
Somehow a hypothesis has crept it that the problem was not a driver JDBC or Charaterset, but because you can not have more than one clob column in a table.You could have easily tested for yourself by doing what P. Forstmann - tried to create a table and see.
Then you completely ignored my advice
>
I suggest to you isolate the columns actually causing the problem.
Change your code to insert only a few columns. When it works, add more than a few columns.
This will then tell you which column or the columns are at the origin of the problem.
Display the results once you determine a column that causes the error.
>
When you have finally made the simplest things, you have found what was causing the problem almost immediately.Many times you don't need 'experts' - you must use a rigorous, methodical, process step by step.
ALWAYS, ALWAYS, ALWAYS reduce the simplest possible code example that illustrates the problem.
If you had followed this a rule would have probably found you the problem and makes you look like the 'expert '.There are no shortcuts.
Maybe you are looking for
-
Qosmio G20-127: after firmware update cannot burn CD or DVD
I'm updating my firmware from F101 F102 to dvd so I can't copy any CD or DVD in my drive also some CD & DVD cannot be played after this update, I tried toinstall the old firmware F101, but I can't so please help me? Thanx
-
Scanning for HP Color LaserJet M476nw MFP
I just installed the software for the MFP476nw. When I scan a page 8.5 by 11, it scans it on a larger size which must be grown before the Save as pdf. This creates a lot of work for a large document when you need to crop each page before saving. What
-
HP ENVY TouchSmart 15 t-j000 Quad Edition PC laptop
I'm looking for except one of the new envys with haswell processors. But after I bought the laptop I want to replace the HDD with a SSD, this new body of the laptop seems really thin and I was wondering if someone again for sure if I'll be able to e
-
I use windows xp. I get a yellow icon in my computer, indicating to install an update, but after trying to install it I get a message that the service pack 4 (kb2463332) was not able to install. How can I solve this? Thank you
-
HP DV6-6135dx compatible >; 9 stacks?
I can't find a specific answer online. I bought a battery battery EVO88AA 12 advertised as compatible with all models of DV6000, but it didn't fit... it does not fit in my old DV2500 notebook. I was wondering if anyone of YOU KNOW THE COMPATIBLE (IF