Retrieve column values is the only character
Hi all
I have a column whose values are the combination of characters and the number. example below.
1L2P - 7 K-004-ADJAEA
3L 24-7825767 - CC5YGY
9030-CAP
LOCK-9030-NOTSERV
NO-10E987-SERV
But I need to retrieve data that has only the character before the 1st dash '-'.
Query for the above values.
WITH SAMPLE_TAB
AS
(SELECT 'NON-10E987-SERV"AS DOUBLE DIGIT
UNION
SELECT ' 1L2P - 7K 004 - ADJAEA "AS THE DOUBLE DIGIT
UNION
SELECT "LOCK-9030-NOTSERV" AS THE DOUBLE DIGIT
UNION
' SELECT ' 3 L 24-7825767-CC5YGY "AS THE DOUBLE DIGIT
UNION
SELECT "FUEL-9030-CAP" AS DOUBLE DIGIT
)
SELECT * FROM SAMPLE_TAB;
Power required:
9030-CAP
NO-10E987-SERV
LOCK-9030-NOTSERV
Enjoy all that help.
Thank you
Hello
MSB says:
Hi all
I have a column whose values are the combination of characters and the number. example below.
1L2P - 7 K-004-ADJAEA
3L 24-7825767 - CC5YGY
9030-CAP
LOCK-9030-NOTSERV
NO-10E987-SERV
But I need to retrieve data that has only the character before the 1st dash '-'.
Query for the above values.
WITH SAMPLE_TAB
AS
(SELECT 'NON-10E987-SERV"AS DOUBLE DIGIT
UNION
SELECT ' 1L2P - 7K 004 - ADJAEA "AS THE DOUBLE DIGIT
UNION
SELECT "LOCK-9030-NOTSERV" AS THE DOUBLE DIGIT
UNION
' SELECT ' 3 L 24-7825767-CC5YGY "AS THE DOUBLE DIGIT
UNION
SELECT "FUEL-9030-CAP" AS DOUBLE DIGIT
)
SELECT * FROM SAMPLE_TAB;
Power required:
9030-CAP
NO-10E987-SERV
LOCK-9030-NOTSERV
Enjoy all that help.
Thank you
Perhaps the easiest way is
...
WHERE REGEXP_LIKE (alphanumeric, ' ^ [[: alpha:]] + -')
You could also write it like this:
SELECT *.
OF sample_tab
WHERE REGEXP_LIKE (alphanumeric
, '^' || -at the beginning of the string
"[[: alpha:]]' |" -alphabetical character (from A to Z according to your language, case insensitive)
'+' || -the above can occur 1 or more times
'-'-(no special meaning) the hyphen character
)
;
Tags: Database
Similar Questions
-
How to store and retrieve long values in the store persistent
Hello
In my application I want to store and retrieve long values in the persistent store that I used with Longvector and all is well, but LongVector is supported for operating system > = 4.6
I need to work my request in 4.5 also, can any one infrom me what are the other alternatives, I have to get my pls any abstract requirement...
Vector v = new Vector();
fill vector
Long premierElement = (Long) v.firstElement ();
myLong long = firstElement.longValue (); -
Select the column values in the collection
Greetings,
I want to select column values from the collection (plsql tables or table), as the following code, would it be possible
Here tt is any collection
Select emp_no, name, date of birth, sal tt (1), tt (2), tt (3), tt (4) emp; -single line query
Select name, Department of justice, strength and dep_no in tt (5), tt (6), tt (7), tt (8) EMP; -single line query
Version
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
Thanks in advanceNot sure about your business needs. But technically you can do.
declare type tbl is table of number; lemp tbl := tbl(); begin lemp.extend; lemp.extend; lemp.extend; select empno , mgr , sal into lemp(1) , lemp(2) , lemp(3) from emp where empno = 7369; for i in 1..lemp.count loop dbms_output.put_line(to_char(lemp(i))); end loop; end;
-
How to find out the ASCII values for the Spanish character
Hello
I had an obligation to maintain the Spanish character and must also always records based on the Spanish character.
Kindly guide me for below.
To filter the records that contains Spanish characters?
To get the ASCII values for the particular column?
For example, we can find the ASCII value of 'a' using the select syntax ASCII('a') double.
But I want to find the value of the particular column ASCII values. That is to say. name.
For example, the customer name is 'Suresh', I want the ASCII values for the entire name of 'Suresh '.
Please do the necessary help / advice on that.
Thank you
OraharTo expand on what I said in my first post, you want to do something in this direction:
with t (thename) as ( select 'Suresh' from dual ) select thename , substr(TheName, level, 1) , ascii(substr(thename, level)) from t connect by level <= length(thename);
The result of the above query is:
THENAM S ASCII(SUBSTR(THENAME,LEVEL)) ------ - ---------------------------- Suresh S 83 Suresh u 117 Suresh r 114 Suresh e 101 Suresh s 115 Suresh h 104 6 rows selected.
Note that the WITH statement is only there to simulate a table for this example. With a table, all you do is get rid of the with and replace it with the name of "t" for your table name (also the name of the column with name column has in your table).
Finally, I suggest that you post your question with, an example of table and the output you want for PL/SQL forum. There are people out there who will give you all sorts of ways to solve this problem.
HTH,
John.
-
Strip column values, set the new column
I'm on 11G, need help with SQL.
I would like to use RegEx, I know 11G supports up to 5 functions, I think maybe REGEX_LIKE, not sure, let me explain.
I have a VARCHAR2 column in my Table which can have different combinations of values:
Example #1:
value (with or without spaces, I call this value0, without a delimiter), example:
Send
Infocourriel
WhiteSpace
More examples
value0 band where no delimiter is used in its own column
Example #2: (values separated by a delimiter <), example:
Gucci < watches < accessories
blah < blah < blabla
blah < blah #$ < blabla
so, I call these:
Value1, value2, value3
band value1 before 1 < in its own column
band value2 before the 2nd < in its own column
remove the 3 value after the 2nd < in its own column
The good thing is that when the separator is used, it is consistent, there are 2 of them: value1, value2, value3
Thank you.Hello
Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables.
Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
If you ask on a DML statement, such as UPDATE, CREATE TABLE and INSERT statements need to re - create the tables as they are before the DML, and results will be the content of the or the tables changed when it's all over.Looks like you want something like:
UPDATE table_x SET value0 = CASE WHEN INSTR (value, '~') = 0 THEN value END , value1 = CASE WHEN INSTR (value, '~') > 0 THEN TRIM ( REGEXP_SUBSTR ( value , '[^~]+' , 1 , 1 ) ) END , value2 = TRIM ( REGEXP_SUBSTR ( value , '[^~]+' , 1 , 2 ) ) , value3 = TRIM ( REGEXP_SUBSTR ( value , '[^~]+' , 1 , 3 ) ) ;
You could use instead of INSTR REGEXP_LIKE, but is not really easier to code, and it will be less effective.
Published by: Frank Kulash, Sep 20, 2011 17:15
This site interprets the < signs such as markup, so I changed the delimiter to ' ~', just to make it clear. You must use < I used ~ above. -
Hello
I use JDev 11.1.1.3
I have a form and a table in the form of my jspx
in my table, I have a column that is not bound 2 DB
in my form, I have a class LOV where I apply value change listener...
When I apply value change listener I want 2 set the value of the column...
Please suggest me a solution
Thanks in advance
Edited by: Venkat Naidu L on March 15, 2011 22:06Try and tell. This should be in quotes. But while coding won't give you any error during compiling.
Reg,
Vini -
Change column values become the row values
Hi, how to make the column values become row values as below, please advise and thanks. SELECT sc.configuration, sc.item_type, st.producttype, st.productfamily, sc.multidrive, sp.internalproductname FROM seaeng_productmodel sp , seaeng_stmodel st, seaeng_ccitemnumber sc WHERE sc.productmodelnumber = sp.productmodelnumber AND sp.stmodelnumber = st.stmodelnumber and sc.ccitemnumber = '9NH2D4-575' Output CONFIGURATION ITEM_TYPE PRODUCTTYPE PRODUCTFAMILY MULTIDRIVE INTERNALPRODUCTNAME CUST UNIQUE CC DRIVE FREEAGENT GO 5400.1 FAMILY N SLIPSTREAM Expected to be converted as below, COLUMN NAME COLUMN VALUE CONFIGURATION CUST UNIQUE ITEM_TYPE CC PRODUCTYPE DRIVE PRODUCTFAMILY FREEAGENT GO 5400.1 FAMILY MULTIDRIVE N INTERNALPRODUCTNAME SLIPSTREAM
You mean like this?
SQL> select * from emp where empno = 7788; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- ------------------- ---------- ---------- ---------- 7788 SCOTT ANALYST 7566 19/04/1987 00:00:00 3000 20 SQL> ed Wrote file afiedt.buf 1 select decode(rn,1,'EmpNo',2,'EName',3,'Job',4,'Mgr',5,'HireDate',6,'Sal',7,'Comm','DeptNo') as column_name 2 ,decode(rn,1,to_char(EmpNo),2,EName,3,Job,4,to_char(Mgr),5,to_char(HireDate,'DD/MM/YYYY'),6,to_char(Sal),7,to_char(Comm),to_char(DeptNo)) as column_value 3 from emp, (select rownum rn from dual connect by rownum <= 8) 4* where empno = 7788 SQL> / COLUMN_N COLUMN_VALUE -------- ---------------------------------------- EmpNo 7788 EName SCOTT Job ANALYST Mgr 7566 HireDate 19/04/1987 Sal 3000 Comm DeptNo 20 8 rows selected. SQL>
-
ADF Table - View column value of the selected line, need help
Hi all
I am newbee in ADF and needed to get the value of the column in the selected line in ADF inputTest.
(I tried to navigate link without success)
Pls tell me is it possible without coding, that is to say using partialTrigger etc.
Please indicate the steps to follow.
Thank you
AmitHello
I'm not clear on your condition, where is your inputtext, is it inside the table or just outside the table?
From my understanding, I realized that you have a table and a text entry next to the table where you want to display the value of a particular column of a selected line. That's what you're looking for (in which case above suggested solution works) or something different?
Jean Lou
-
Change a column value in the reports
Hi all
I have a column that contains values such as 12345678, 78945612, etc... Now, I wanted to change the values like 123-45678, 789-45612 etc...
Baiscally this field is an 8-digit integer, and I would like to insert the dashboard after three digits. Is it possible to do in OBIEE. If so how this requirement can be achieved.
Thank you
Hello
Please check the screenshot with the insert function and conform the same results you expect
Kind regards
Drupada
-
Update the column values with the new user who has changed the data in the current line
I have a table, the following structure.
CREATE TABLE FILTERCALENDAR1
(DATE OF THE "C_DATE',
NUMBER (1,0) 'DAY_OF_WEEK ',.
NUMBER (1.0) "WEEK_WINDOW."
NUMBER (1.0) "MONTH_WINDOW."
NUMBER (1.0) "YEAR_WINDOW."
NUMBER (1.0) "DATE_YEAR_WINDOW."
NUMBER (1.0) "ONCE_WINDOW."
VARCHAR2 (25 BYTE) "USERNAME."
"LASTUPDATED" DATE
);
Problem:
If a user changes the value of one of the columns I want to write his name to user and sysdate in the 'USERNAME' and LASTUPDATED' columns.
* Tried: *.
I tried an update trigger for this problem, but I get an error table mutation.
The one you suggest how can I achieve this.
ConcerningUse BEFORE the UPDATE trigger
CREATE OR REPLACE TRIGGER myTrigger before UPDATE ON FILTERCALENDAR1 FOR EACH ROW BEGIN :new.USERNAME := user; :new.LASTUPDATED := sysdate; END;
-
column values with the same key value addition
Dear professionals,
I created the table like this:
How to write a query for this data set:create table acc_test ( id number, col1 varchar2(20), col2 number, col3 number); insert into acc_test (id,col1,col2,col3) values ('1','ttt','10','15'); insert into acc_test (id,col1,col2,col3) values ('1','aba','5','0'); insert into acc_test (id,col1,col2,col3) values ('2','abc','12','7'); insert into acc_test (id,col1,col2,col3) values ('3','ddd','6','15'); insert into acc_test (id,col1,col2,col3) values ('3','df','4','15'); insert into acc_test (id,col1,col2,col3) values ('4','kl','10','15');
THX in advance,ID COL1 COL2 COL3 ---------------------- -------------------- ---------------------- ----- 1 ttt 15 (10+5) 15 (15+0) 2 abc 12 7 3 ddd 10 (6+4) 30 (15+15) 4 kl 10 15
AdnanYou can use this query:
SQL> SELECT id,col1,SUM(col2) OVER (PARTITION BY id) col2 2 ,SUM(col3) OVER (PARTITION BY id) col3 3 FROM acc_test ; ID COL1 COL2 COL3 ---------- -------------------- ---------- ---------- 1 ttt 15 15 1 aba 15 15 2 abc 12 7 3 ddd 10 30 3 df 10 30 4 kl 10 15 6 rows selected.
However, if you notice that you can find that the two lines as
ID COL1 COL2 COL3 ------- -------------------- ---------- ---------- 1 ttt 15 15 1 aba 15 15
are present in the result set. Now, he must explain that you want to remove, and why.
If you say, it is not important, then with the data of your second posting, it's even easier!
SQL> SELECT id,col1,SUM(col2) 2 ,SUM(col3) 3 FROM acc_test 4 GROUP BY id,col1 5 ORDER BY 1 ; ID COL1 SUM(COL2) SUM(COL3) ---------- -------------------- ---------- ---------- 1 ttt 15 15 2 abc 12 7 3 ddd 10 30 4 kl 10 15
Published by: Johan on November 24, 2010 16:48
-
How to examine the date as 1 column value if the value of the column date is same?
Hi all
With trunc
SELECT pointed_date,
Qty.
OF () SELECT Trunc (pointed_date) pointed_date,.
SUM (Nvl (quantity, 0)) Qty.
FROM table_1
WHERE pointed_date > = Add_months (trunc (sysdate),-4)
GROUP BY pointed_date( )
ORDER BY pointed_date DESC
output
28/01/2015-30
28/01/2015-30
Without trunk
SELECT pointed_date,
Qty.
FROM (SELECT pointed_date , pointed_date,)
SUM (Nvl (quantity, 0)) Qty.
FROM table_1
WHERE pointed_date > = Add_months (trunc (sysdate),-12)
GROUP BY pointed_date)
ORDER BY pointed_date DESC
output
28/01/2015 01:01:56 - 30
28/01/2015-30
Suppose if I get two dates with less time diff then do as a Date like
28/01/2015-30
28/01/2015-30
EXPECTED
28/01/2015-60
Thank you
run something like below (you might indeed not have more than 9 months of data in the range you are looking at)
Select months_between (sysdate, min (pointed_date)) months_of_data
FROM table1
where pointed_date > = add_months (sysdate,-12)
Concerning
Etbin
-
separated by commas of the column values in the row values
Hi all
I select data in TABLE A (id number, varchar2 rights). result set under
RIGHTS OF THE ID
1 M, P, Y, N, C, P
4 N, E, HAS
10 N, C, R, P
but I want that output voltage
RIGHTS OF THE ID
1 M
2 s
1. IS
0 /.
1 C
2 s
4 N
4 E
$1
10 N
10 C
10 R
20 s
kindly share your idea to get the desired results.
Thanks in advance
Edited by: 887268 November 30, 2012 23:12Try this
SQL> WITH a(id, rights) AS 2 ( 3 SELECT 1, 'M,P,Y,N,C,P' FROM dual UNION ALL 4 SELECT 4, 'N,E,A' FROM dual UNION ALL 5 SELECT 10, 'N,C,R,P' FROM dual) 6 SELECT id, regexp_substr(rights, '[^,]+',1,level) res 7 FROM a 8 CONNECT BY level - 1 <= regexp_count(rights,',') /* regexp_count:- 11g */ 9 AND prior id = id 10 AND prior sys_guid() IS NOT NULL /* sys_guid:- 11g */ 11 ORDER BY id 12 / ID RES ---------- -------------------------------------------- 1 M 1 P 1 Y 1 N 1 C 1 P 4 N 4 A 4 E 10 N 10 R ID RES ---------- -------------------------------------------- 10 C 10 P 13 rows selected.
Thank you!
Published by: Ashu_Neo on December 1, 2012 21:43
-Add a comment -
Display a value in the column only if the number is greater than 1
I need to return a value in the only if column the the count is greater than 1 for the same column.
Example table:
FOOD_TYPE Agenda COST_TO_BUY SELL_PRICE Ice cream Chocolate 0.50 2.00 Ice cream Vanilla 0.50 2.00 Ice cream Strawberry 0.50 2.00 Chicken Wings 2.00 5.00 Bovine meat Steaks 8.00 15 h 00 Bovine meat Roast 10 h 00 6:00 pm In this example, I want to choose the POINT of FOOD_TYPE, SUM (COST_TO_BUY) AND SUM (SELL_PRICE), but I want only to select the ITEM if there is more than 1 points in the FOOD_TYPE.
I tried all kinds of grouping and even including a case statement in select it as follows:
CASE
WHEN (COUNT (DISTINCT POINT) > 1)
THEN THE POINT
ELSE "
END
However, this is denied when I group because it forces me to use the POINT as a group and I can't use the set statement in the GROUP BY because it has an aggregate function.
Help, please!
with
power as
(select food_type 'Beef', 'Steaks' article, cost_to_buy 8.00 15.00 sell_price of all the double union)
Select 'Beef', 'Roast', 10.00, 18.00 double Union all
Select 'Chicken', 'Wings', 2.00, 5.00 double Union all
Select 'Ice Cream', 'Chocolate', 0.50, 2.00 double Union all
Select "Ice Cream", "Vanilla", 0.50, 2.00 double Union all
Select "Ice Cream", "Strawberry", 0.50, 2.00 double
)
Select food_type 'Type of food. "
cases where the head (separate) over (partition food_type) > 1 then end point "Item,"
TO_CHAR (cost_to_buy, 'fm990.00') "Purchase cost"
TO_CHAR (sell_price, 'fm990.00') 'selling price '.
food
food_type desc order
Food Type Item Purchase cost Sell Price Ice cream Chocolate 0.50 2.00 Ice cream Strawberry 0.50 2.00 Ice cream Vanilla 0.50 2.00 Chicken - 2.00 5.00 Bovine meat Roast 10 h 00 6:00 pm Bovine meat Steaks 8.00 15 h 00 Concerning
Etbin
-
Retrieve the Position of the last character of Textlayer
Dear script Experts!
I wonder if there is a way to get the properties of the position of the last character in a text layer.
For example, I used this in ActionScript: txt.getCharBoundaries (txt.length - 1);Thanks for any help
Mike
Available properties for a text layer are:
applyFill
applyStroke
Dialoguegeneral
boxTextSize
fillColor
Police
fontSize
Justification
pointText
strokeColor
strokeOverFill
strokeWidth
text
follow-up
Last I saw, by the data type character recovery was still not available. Even in AE CC. Any extraction layer text property is based on the first character in the text string. So if each character used a font, point size, kerning, etc. only the values of the first character could be found.
Re: Is it possible to access the text by character properties via script?
Some other posts here that speak of the location of the text layer:
Attribute boxTextSize ADBE Text Document
Get a text box anchor point after scaling
You can always ask too.
Maybe you are looking for
-
How to change the download folder?
I use firefox for android and I couldn't change the (default) download folder.It should be added in order to change this setting, I think. THX
-
Purchase of upgrade of Windows 8 $14,99 - a few questions
I know it's more a matter of Microsoft, but I thought that some people here are likely to answer my specific questions including HP. I recently bought a new laptop with Win 7. Although I am happy with Win 7 and do not know if I would be just as happy
-
Hello I would like to install the Bluetooth Module (483113-001) and cable (531811-001) according to page 4-43 Maintenance and Service of Guide (Document part number: 512424-001). Be reluctant (shy) to take my laptop out to see if there is a port of t
-
Unable to detect my drive external hard usb under Windows 7
Ideas: When I plugged the drive show anything at all (it worked perfectly fine in my previous operating system, Windows Vista) connection to printer and my other work OK flash drive. The ports are in agreement. It does not appear in Win explore or De
-
We have a Manager call we use for AA to provide wishes and staff of mailbox access mailbox option and no DDI extension before you send us the receptionist (Call Manager driver Point to the monitoring console). Greeting for office hours and the other