How to get the first 6 digits and the last 4 digits of a string?
Greetings people.A small question and probably quite simple for a lot of guys out there.
I have a string which can be anywhere between 15 and 20 characters (not a fixed length)
I can't be divided into 3 segments.
Segment 1 : 123456 ( 6 digits )
Segment 2 : Everything else in the string from where Segment 1 ends (+1) and Segment 3 begins (-1).
Segment 3 : 1234 ( 4 digits )
Any help is appreciated!Thank you
select substr (str, 1, 6)
, substr (str, 7, length (str) -10)
, substr (str, -4)
from test
Tags: Database
Similar Questions
-
How to get the last 50 characters in a string
Hi, I need to get 50 last characters in a piece of 25 characters each in two columns if the column notes less than 50 characters ex: 43 then I need to last 25 one column and left (18 characters) in the second column. I tried using substr and the first column of length functions fine, but the second column has a problem: select substr ("ABCDEF GHIJ', length('ABCDEF GHIJ')-25, 25) of double; Thanks, Kiran
Hello
what I understand: if I call 'x' the length of the string:
IF x > is 50 THEN result1 is 25 tanks, result2 = 25 characters
IF 25< x="">< 50 ="" then="" result1="25" chars,="" result2="(" 25="" -="" x="" )=""> >
IF x<= 25 ="" then="" result1="x" chars,="" result2="">=>
Note that SUBSTR (x, n) selects the n last characters:
SELECT SUBSTR ("ABCDEFGH",-3) FROM dual-> ANUS
For example AS
(SELECT "AAAAABBBBBCCCCCDDDDD" double str
UNION ALL SELECT 'AAAAABBBBBCCCCCDDDDDEEEEEFFFFFGGGGG' FROM dual
UNION ALL SELECT 'this_is_exactly_25__chars' FROM dual
UNION ALL SELECT 'This___is___exactly___fifty___characters' FROM dual
UNION ALL SELECT 'AAAAABBBBBCCCCCDDDDDEEEEEFFFFFGGGGGHHHHHIIIIIJJJJJKKKK' FROM dual
)
SELECT str
LENGTH WHEN CARTER (str)<>
THEN str
WHEN LENGTH (str)<>
THEN SUBSTR (str, 1, 25)
Of OTHER SUBSTR (str, LENGTH (str) - 49: 25)
END performance(1)
, LENGTH WHEN CARTER (str) > = 50
THEN SUBSTR (str,-25)
WHEN LENGTH (str) > 25
THEN SUBSTR (str, 25 - LENGTH (str))
ANOTHER NULL
End result2
SAMPLE
;
STR RESULT1 RESULT2
------------------------------------------------------ ------------------------- -------------------------
AAAAABBBBBCCCCCDDDDD AAAAABBBBBCCCCCDDDDD
AAAAABBBBBCCCCCDDDDDEEEEEFFFFFGGGGG AAAAABBBBBCCCCCDDDDDEEEEE FFFFFGGGGG
this_is_exactly_25__chars this_is_exactly_25__chars
This___is___exactly___fifty___characters This___is___exactly_ ___fifty___characters
AAAAABBBBBCCCCCDDDDDEEEEEFFFFFGGGGGHHHHHIIIIIJJJJJKKKK ABBBBBCCCCCDDDDDEEEEEFFFF FGGGGGHHHHHIIIIIJJJJJKKKK
Best regards
Bruno Vroman.
-
How to get the last day of the week?
HII
I can get the week number of calendar for a given date using
SELECT to_char (to_date('04/04/2011','MM/DD/YYYY'), 'WW') FROM dual
can any body tell me, how to get the last day of the week?
and the answer should be: 04/08/2011(8th april)
Thank you
San
Published by: sandeep9 on April 4, 2011 03:50Perhaps this...
SQL> select trunc(sysdate,'WW')+6 from dual; TRUNC(SYSDATE,'WW')+ -------------------- 08-APR-2011 00:00:00 SQL>
-
How to get the last date of 3 days for the current month?
Hello. Guy
How to get the last date of 3 days for the current month?
MY OUTPUT WOULD LOOK LIKE THIS
JANUARY 29, 2016
JANUARY 30, 2016
JANUARY 31, 2016
GUYS HELP ME / / /...
SQL > select last_day (sysdate) - level + 1 double connect by level<= 3="" order="" by="">=>
LAST_DAY)
---------
29 JANUARY 16
30 JANUARY 16
31 JANUARY 16
-
How to get the last day of a month for every 2 months for a given period?
Hello
Can is it some please let me know how to get the last day, last day of the week, the weekend last day, last Monday, one month for every 2 months for a given period?
Thanks in advance.
Try the below
SELECT LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))) lastday.
BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'SAT '.
SO LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))-1
WHERE TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'Sun '.
THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))-2
Of OTHER LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))
END as lastweekday,
BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') IN ('Sam', 'SUN')
THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))
Of OTHER LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))
-(TO_NUMBER (TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))),' from)) - 1).
END as lastweekendday,
BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'MY
THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))
Of OTHER NEXT_DAY (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), "LUN")-7
END AS lastmonday
FROM (SELECT SYSDATE startdate,
SYSDATE + 300 enddate
THE DOUBLE)
CONNECT BY LEVEL<=>=>
-
How to get the last row and the sum of all columns in a query
Hello
is there a way to get the last record for a column and the sum of all the Archives to another column in the same query.
Best regards
You must set your needs correctly volunteers to help here...
Your data are not good enough to bring you a precise solution. Purpose, you do not have a column, which draws a distinction between the first and the last entry.
The solution becomes easy based on your design.
I introduced a grouping called 'id' column and a time column called 'time_of_insert' (only this way you can say with confidence that you can differentiate between the first and last (also a foolproof solution) - you can possibly use sequence (instead of date but if you say that you can insert two lines at the same time) ((and then likely sequence would be a better choice to differentiate instead of a timestamp field) etc...)
With your sample data, something like this can be done to get the desired results.
-----------------------------------------------------------------------------------------------------------------------
WITH dataset AS
(SELECT 1 id, 10 used, 8 remain, systimestamp + 1/24 time_of_insert FROM DUAL
UNION ALL
SELECT the 1 id, 1, 7, systimestamp + 2/24 FROM DUAL
UNION ALL
SELECT the id 1, 2, 5, systimestamp + 3/24 FROM DUAL
UNION ALL
SELECT 1 id, 1, 0, systimestamp + 4/24 FROM DUAL
UNION ALL
SELECT 1 id, 0, 0, systimestamp + 5/24 FROM DUAL
UNION ALL
SELECT the 1 id, 1, 4, systimestamp + 6/24 FROM DUAL)
SELECT *.
(SELECT SUM (used) ON sum_all)
FIRST_VALUE (stay)
COURSES (PARTITION BY id ORDER BY time_of_insert DESC)
last_row
Of THE dataset)
WHERE ROWNUM = 1;
Output:
------------------------
SUM_ALL LAST_ROW
------------------------------
15 4
See you soon,.
Manik.
-
How to get the last message received in the Inbox?
Currently I am using the following code to the list of messages in the Inbox.
Folder[] folders = store.list(Folder.INBOX);Folder inbox = folders[0];Message[] msgs = inbox.getMessages();
But, how could I do the last message that was received in my inbox at the moment?
I have a lot of unread messages in my Inbox and I can even receive the same message from sender twice at the same time, but I need access to the last message you received.
Thank you
As I have a implements FolderListener, I need to get the last message of FolderEvent object. But, I tried to access the last Inbox message, which will not always be there!
Thanks Deepesh
-
Hello my friends.
I am looking for information on how to get the date of the access and the user name who did use some WFs in OM and last WMS.
If it is through the application or running in the background via SQL for the information is not important to me.
Could you help me with this?.
Thank you
the 'item_type' attribute must match the name of the WF?
Yes (internal name. For example OEOL).
The custom of those who will not be affected by the upgrade.
You must run the query that I provided before to identify if the workflow is used or not.
For the workflow of order lines, it is intended to be used as you use the order management.
Kind regards
Bashar
-
How to get the last parameter of exprision regular
Hi all!
I need to extract the last date in the string.
Here my code
How can I get the last datePattern pattern = Pattern.compile("(19|20)\\d\\d([- \\\\/.](0[1-9]|1[012])[- \\\\/.](0[1-9]|[12][0-9]|3[01]))?"); Matcher matcher = pattern.matcher(text); while(matcher.find()) { System.out.println(matcher.group());
Example->
Hello all the date is 2010-12-12 the date is 2010-10-10
and I want to get-> 2010-10-10
Thank you!Just assign the value of the find to a variable declared outside the loop. The variable will hold the last game when you exit the loop.
Kaj
-
How to get the last day of the year
Hi all
Thanks in advance...
How do I get the last day of the year that I'm passing date at run time.
I can manage to get the first day of the year by
SELECT TRUNC(SYSDATE,'YEAR') AS FDAY_YEAR
of the double
Thanks in advance
Concerning
Sachin1* select ADD_MONTHS(trunc(sysdate,'yyyy'),12)-1 dd from dual SQL> / DD ----------- 31-DEC-2010
-
How to get the last business day of the previous month?
Hi all
We need the user as below,
If the user select 18 June 2015 ' quick dashboard as the input value, and then they want to see last month last day of work (business date: 29-may-2015) amount in report, if you have an idea please share with us.thanks
Note:
use under request we can able to get the last day of the previous month, we want to for the last business day of the last month, based on the date of entry of the user?
TIMESTAMPADD (SQL_TSI_DAY,-(1), TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH ("DIM_TIME". ("" DataDate ") *-(1) + 1,"DIM_TIME ". (("" DataDate "))
Thank you
Deva
Try this,
case when Dayofweek (timestampadd (sql_tsi_day, Dayofmonth(Date '2015-06-15') *-1, Date ' 2015-06-15')) = 1 then timestampadd (sql_tsi_day, (Dayofmonth(Date '2015-06-15') *-1)-2, Date '' 2015-06-15) when Dayofweek (timestampadd (sql_tsi_day, Dayofmonth(Date '2015-06-15') *-1, Date ' 2015-06-15')) = 7 then timestampadd (sql_tsi_day, Dayofmonth(Date '2015-06-15') *-1-1, Date '' 2015-06-15) another timestampadd (sql_tsi_day, Dayofmonth(Date '2015-06-15') *-1, Date ' 2015-06-15') end
As Ftsiot said in this post, it will work only to exclude the sat and Sun. Another one if you want to exclude regional holiday, you may need a calendar in DB table.
Thank you
AJ
-
How to get the last day of the weekend rather than a month
Hi all
Is the request appropriate and preferable to use to get the last business day of the month below?
SELECT to_date('13.08.2014','dd.mm.yyyy') + MAX(RNUM) LastDay(nonweekend) FROM (SELECT ROWNUM RNUM FROM ALL_OBJECTS where rownum <=31) WHERE ROWNUM <= 31 ANd TO_CHAR(to_date('13.08.2014','dd.mm.yyyy') + RNUM, 'DY','NLS_DATE_LANGUAGE=ENGLISH' ) NOT IN ('SAT' , 'SUN') and to_date('13.08.2014','dd.mm.yyyy') + RNUM <= last_day(to_date('13.08.2014','dd.mm.yyyy'))
I have to use this motion for production.
East - recommended to use?
You can change your query this way:
WITH t AS (SELECT trunc (to_date ('& calc_date', 'dd.mm.yyyy'), 'mm') + level - 1 calc_date)
OF THE DOUBLE
CONNECT BY LEVEL<= last_day(to_date('&calc_date',="" 'dd.mm.yyyy'))="" -="" trunc(to_date('&calc_date',="" 'dd.mm.yyyy'),="" 'mm')="" +="">=>
)
Select max (calc_date)
t
where to_char (calc_date, 'DY', 'NLS_DATE_LANGUAGE = ENGLISH') NOT IN ("SAT", "Sun");
-
Hi I have a senerion in which I want to get the last value: -.
CREATE TABLE T1 (NAME VARCHAR2(10), NO NUMBER, NO2 NUMBER); INSERT INTO T1 VALUES('A',10,20); INSERT INTO T1 VALUES('C',100,2); INSERT INTO T1 VALUES('B,124,5); INSERT INTO T1 VALUES('A',1,400); INSERT INTO T1 VALUES('B,2,234); INSERT INTO T1 VALUES('B',2,7); INSERT INTO T1 VALUES('C',21,12); INSERT INTO T1 VALUES('A',3,300); INSERT INTO T1 VALUES('B,55,1); INSERT INTO T1 VALUES('C',234,1); INSERT INTO T1 VALUES('B',20,72); INSERT INTO T1 VALUES('A',200,0); INSERT INTO T1 VALUES('B',546,32); INSERT INTO T1 VALUES('C',89,888); INSERT INTO T1 VALUES('B',485,12); INSERT INTO T1 VALUES('C',1,77); INSERT INTO T1 VALUES('B',339,12); INSERT INTO T1 VALUES('A',0,300); {\code} Now for all A i want the value (order by name,no,no2) i.e value of no2 0 for all b i want 32 and for all c i want 1 i.e last value in order by clause. i tried this select name,no,no2,last_value(no2) over(PARTITION BY name order by no,no2) nm from t1 can anyone please help me? Thanks Edited by: vinod on Jan 6, 2012 8:58 PM
-
How to get the last payroll assignment_action_id
Hello
I have requirment, I have to get the last assignment_action_id can some body live or send me the query?
pay_assignment_actions
pay_payroll_actions
I use the following question, is it OK to use?
SELECT MAX (assignment_action_id)
OF pay_assignment_actions PAA.
pay_payroll_actions App
WHERE assignment_id = 575758
AND ppa.payroll_action_id = paa.payroll_action_id;
Thank you.I would like to add a filter on the action_type (R = p = Run, Q = Express, P = charges paid in advance, C = costing,...)
-
How to get the last DML statement in each block
Hello
How can I get the latest DML statements in each block.
As SYSTEM. LAST_QUERY returns the last select statement, I need to get the last Insert/Update/Delete statement
in each block.
Thanks in advance
RizlyRizly,
You can use the GET_BLOCK_PROPERTY to get the last query executed on this block.
MESSAGE(GET_BLOCK_PROPERTY('
', LAST_QUERY)); Kind regards
Manu.
If this answer is useful or appropriate, please mark. Thank you.
-
Hi I can understand my way to get the latest cpu and psu of metalink. But I don't get to see the latest Opatch utility.
Care to give me a little help here?field of research: opatch
the first hit: master Note for OPatch [293369.1 ID]
Scroll to the bottom, first related note: OPatch Note 224346.1 - where can I find the latest Version of OPatch?
was not that it was hard.BTW its patch 6880880
Maybe you are looking for
-
need to reset my HP ENVY 17 t-k000 CTO Notebook PC (ENERGY STAR)
HP ENVY 17 t-k000 CTO Notebook PC (ENERGY STAR) I need a recovery kit for my cause of laptop I did upgraded for Windows 8, Windows 10 but it shows not winth 10 windows partition so I can't launch the LT. I have contact the HP SUPPORT but no way of di
-
Reference DELL 5548 syslog problem
Hello I think 5548 switches syslog bug. command "show logging" indicates: May 16, 2014 09:25:38: % LINK-w-Up: item in gi1/0/25May 16, 2014 09:25:35: % LINK-W-Down: item in gi1/0/25 Syslog receives: May 16 09:25:35 192.168.0.1 LINK Hostname: , article
-
How to resize controls to get the width
Hi guys,. I will try to find a way to not hard code the width/height of the controls, checked a way to use 'USE_ALL_WIDTH' of bb4, but the DockLayout method, but the solution in this thread will not work, because I can not find DockLayoutProperties:
-
How to install the 32-bit software on my Windows 7 Home Basic 64-bit?
I use the family Windows 7 Edition Basic 64-bit. Now I want to install a 32-bit program (software of Rockwell RSView32) which works well on Windows XP Service Pack 2, but the installation of the program Wizard does not open in my Windows 7 Home Basic
-
The Task Manager does not work in Windows 7
In Windows 7 Task Manager no longer works. I press Ctrl-Alt-Del and nothing seems to happen once I select "Task Manager"in the menu. I don't have the software for Windows disk because I bought from Best Buy HP desktop with Windows software loaded in.