Add a string to the last record
HelloI was just trying to format an o/p to a table, and looking at the result, I thought it would be nice to add a piece of a chain to the last record. For example
with dat as (
select 'First Record' as COL from DUAL
union all
select 'Second Record' from DUAL
union all
select 'Third Record' from DUAL
union all
select 'Nth Record' from DUAL )
select * from dat
o/p Desired o/p
COL COL
------------- -------------
first RECORD first RECORD
second RECORD second RECORD
THIRD RECORD THIRD RECORD
NTH RECORD This is the last record NTH RECORD
with dat as
(
select 'First Record' as COL from DUAL
union all
select 'Second Record' from DUAL
union all
select 'Third Record' from DUAL
union all
select 'Nth Record' from DUAL
),
ord as
(
select count(*) rn
from dat
)
select decode(rownum, rn, 'This is Last Record ' || col, col)
from ord, dat;
Tags: Database
Similar Questions
-
Select the last record of each month
Hello
to select the last docnumber and qty of every month
Structure
Name Null? Type
------------------------------- -------- ----
PRODUCTCODE NUMBER
NUMBER NUMBER
DATE OF PLANFORMONTH
NUMBER OF CLEXPECTEDQTY
NUMBER OF CLCONFIRMQTY
NUMBER OF CLFGBUFFERQTY
NUMBER OF CLTOTPRINTBUFFER
in this select query if I take the sum he required all records where, as I want the last record of each month
SELECT productcode docnumber MAX (Number), planformonth, SUM (clexpectedqty) clexpectedqty (planformonth) MAX.
SUM (clconfirmqty) clconfirmqty, SUM (clfgbufferqty) clfgbufferqty, cltotprintbuffer OF FGSALESPLAN of the SUM (cltotprintbuffer)
GROUP BY productcode, (planformonth)
Sandy
Hello
Thanks its working now the code is written as below:
SELECT * FROM
(SELECT
e.*,
ROW_NUMBER() OVER (partition by PRODUCTCODE by DOCNUMBER DESC order) r
Of
E FGSALESPLAN)
WHERE r = 1 AND
entryvalid = 'Y '.
order by Number
Sandy
-
How to add a string to the end TLFTextField without losing the current text format!
- I have a TLFTextField which loads the text of the external text file.
- Then a function changes the format of certain parts.
- Then, as soon as I add a string to the end my TLFTextField, all previous formatting is lost!
I use this code to add the string:
- myTLF.text += ".";
or
- myTLFText.text = myTLFText.text.concat(".");
Should I use another method?
pass again the text through your function put shaped, or try appendText:
- myTLF.appendText(".");
-
Regex to replace all occurrences of an empty string, except the last
Hello, everyone!
I need get to a regular expression to replace all occurrences of an empty string except the last. Right now I'm doing this with this code:
As you can see, to do this, I have to make two calls: one for replaceAll and another for replaceFirst to get rid of the last character. So I would like to get rid of the call to replaceFirst and have the variable of regex as being a regular expression that would be to insert the character along the chain of all but the last. I'm really not very good with regexs, so I ask your help here. The thing I work, but I think it would be more elegant with just a regex to do.public static void main(String[] args) { String str = "abc"; String regex = ""; System.out.println(str.replaceAll(regex, "-").replaceFirst("-$", "")); // -a-b-c }
Thank you in advance.
MarcosTry this:
String data = "abc"; System.out.println(data.replaceAll(".", "-$0"));
-
remove the last record from the plsql table
Under certain conditions, I need to remove the last record from i_CustomerLoopTYPE r_LOOPElement IS RECORD (TermID NUMBER ); TYPE t_LOOPType IS TABLE OF r_LOOPElement INDEX BY BINARY_INTEGER; i_CustomerLoop t_LOOPType ; i_CustomerLoop(1).TermID=1; i_CustomerLoop(2).TermID=2; i_CustomerLoop(3).TermID=3;
whichi s the best way to do it. because I sometimes get duplicates for TermID in this plsql table.Hello
See [removing items from Collection (DELETE method) | http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/collections.htm#CJAFGFIG]
Kind regards
-
What is the best way to get the last record in a table?
... in addition to select * from tbl by id Desc... & then set = 1 maxrow in cfoutput.
I want a quick way.
I tried "Max (id), columns, but not worked.
If I ' Max (id) as V ' & then turn around and make another request for ' where id = #V # "to get the rest of the record, there's more action.
Quote:
Posted by: paross1
One way...SELECT all your columns
From your_table
WHERE your_engagement_appid = (SELECT MAX (your_id)
From your_table)Phil
Thank you guys. It worked great.
I also tried the front joined query where the... I would have thought that.
Thank you! -
Cursor Oracle return only the last record
I am a newbie in oracle stored proc. I tried to select data using the slider, but it only return last record. The recording must be greater than 1.
CREATE or REPLACE procedure MySchema.Test (myrefcur on sys_refcursor)
Is
Begin
declare
Cursor C1 IS
Select mySerialNum from TableA;
MyRecord C1% rowtype;
Begin
Open C1;
Loop
Fetch C1 into myrecord;
When the output C1% NotFound;
Open for Myrefcur
Select SerialNumB from TableB where SerialNumB = myrecord.mySerialNum;
End loop;
Close C1;
End;
end;
However, it only returns the last record in the list.
Original case *.
The original code is as below:
1st, I'll need to select a list of ImageSerialNum of ImageSerial
* 1 query:
Select A.ImageSerialNum from ImageSerial A, ProductionOrder B, Bom C
Where A.ProductionOrderID = B.ProductionOrderID And B.Assembly_Num = C.Model_Num and
B.Revision = C.Revision And B.EngRevision = C.EngRevision and
C.Bom_ID = passInVariable* and C.FactoryID = "7"
2nd, I'll need to check the process of EACH series with the code below:
* Low code a return process for 1 series only.
Select t.processid, t.processname, t.assembly_num, t.revision, t.engrevision of
(Select p.ProcessID, p.ProcessName, in. Assembly_Num, in. review, in. EngRevision, im.imageserialnum
Process p, Routesequence rs, Imageserial im, ProductionOrder in.
Where im. ImageserialNum = SerialNum* and p.ProcessID = rs. ProcessID
And rs. RouteID = in. RouteID and rs. SequenceID = im. NextRouteSequence
And in. ProductionOrderID = im. ProductionOrderID AND IM. STATUS OF '0'
UNION
SELECT A.REWORKROUTEID AS PROCESSID PROCESSNAME AS B.ROUTENAME, C.ASSEMBLY_NUM, C.REVISION, C.ENGREVISION, a.imageserialnum
OF IMAGESERIAL A, B OF ROAD, PRODUCTIONORDER C
WHERE A.REWORKROUTEID = B.ROUTEID AND A.IMAGESERIALNUM = SerialNum*.
AND A.PRODUCTIONORDERID = C.PRODUCTIONORDERID and a.status = '0') t
After that, I would like to combine the two in 1 stored proc code.in this case, you just want to join the two applications to use in the FROM clause
As I don't have your tables, I created two tables, each representing the results of your queries. Substitute the names of table with your queriesSQL> drop table master 2 / Table dropped. SQL> drop table details 2 / Table dropped. SQL> SQL> create table master 2 (ImageSerialNum varchar2(25)); Table created. SQL> SQL> SQL> insert into master values ('Serial1'); 1 row created. SQL> insert into master values ('Serial2'); 1 row created. SQL> insert into master values ('Serial3'); 1 row created. SQL> insert into master values ('Serial4'); 1 row created. SQL> insert into master values ('Serial5'); 1 row created. SQL> SQL> create table details 2 (ImageSerialNum varchar2(25) 3 ,ProcessID number 4 ,ProcessName varchar2(25) 5 ); Table created. SQL> SQL> insert into details values ('Serial1', 1, 'Process1'); 1 row created. SQL> insert into details values ('Serial3', 3, 'Process3'); 1 row created. SQL> insert into details values ('Serial5', 5, 'Process5'); 1 row created. SQL> SQL> select m.imageserialnum 2 , d.processid 3 , d.processname 4 from master m 5 left outer 6 join details d 7 on (m.imageSerialnum = d.imageserialnum) 8 order by m.imageserialnum 9 / IMAGESERIALNUM PROCESSID PROCESSNAME ------------------------- ---------- ------------------------- Serial1 1 Process1 Serial2 Serial3 3 Process3 Serial4 Serial5 5 Process5
your query will be something like
select m.imageserialnum , d.processid , d.processname from (
) m left outer join ( -
Format the first and the last record of query result
Hello
I have the following query
< tt > select 1 seq, "This is the first record" data from dual union of all the
Select 2, 'Data ' | tNom tab Union all
Select 3, "It was last last record" double
order by 1 < /tt >
When I have the coil this summary to a listfile with col seq noprint option I get:
This is the first record
Data MLA_ACCESS_LIST
Data MLA_APPLICATIONS
Data MLA_VPD_PCK
Data MLA_VPD_TABLES
It was the last last record
But I want to:
It's first record MLA_ACCESS_LIST
Data MLA_APPLICATIONS
Data MLA_VPD_PCK
MLA_VPD_TABLES it was save finally last record
I tried with 1 statement with the use of lead and lag, because first and last record stand the other result record. But I get ORA-30484: lack of specification of the window for this function
Is this possible with 1 statement or am I've sentenced to modify the results by myself?
Thank you AukeSelect row_number() case above (tNom control)
When 1 then 'it's the first record
end | tNom |
-case row_number() over (order by desc tNom)
When 1 then 'it was the last record. "
end
tab
order by tNomHTH
-
Identify the last record of node
Hello everyone,
another day, another problem.
We want to display a list of commands not as multiple lines but as single line, each value divided by a comma:
<? for-each: BM_AUFTRAEGE_ROW? > <? KRA_AUFTRAG_NUMMER? >, <? end foreach? >
My concern is how to remove the last comma in this line? Can I calculate if it is the last recording of an if statement?
Regrads,
Stefan DaseTo do this
= ,
-
How to find the last record of the extracted records
Dear members,
I have an OFA Page in which I view record master detail. For each master record can one or more detail records.
In the page I got the button NEXT. If the user clicks the next button, I'm populating the next record of the master and its corresponding detail records.
To achieve this, I wrote the code below in AM:_
Public Sub findNextRec()
*{*
String headerID = null;
Rank rank is getMaster_VO1 () .next ();.
if(Row!=null)
*{*
headerID = row.getAttribute ("HeaderId") m:System.NET.SocketAddress.ToString ();
getDetail_VO1 (.setMaxFetchSize(-1));
getDetail_VO1 () .setWhereClause (null);
getDetail_VO1 () .addWhereClause ("header_id in (: 1)" ");
getDetail_VO1 () .setWhereClauseParams (null);
getDetail_VO1 (.setWhereClauseParam(0,headerID));
getDetail_VO1 () .executeQuery ();
*}*
*}*
My CO code in processFormRequest method is as follows:_
If (PageContext.GetParameter ("Next")! = null)
*{*
am.invokeMethod ("findNextRec");
*}*
Here my requirement is that if it's a last drive, I want to show the user a message saying it's last recording. To achieve this please let me know what the code should be written.
Thanks in advance.
Best regards
Arun D. ReddyArun,
If my interpretation is correct, then you can achieve the same thing by making some minor changes to your existing code.
public void findNextRec() { String headerID=null; Row row = getMaster_VO1().next(); if(row!=null) //your code will return null when if there is no record { headerID=row.getAttribute("HeaderId").toString(); getDetail_VO1().setMaxFetchSize(-1); getDetail_VO1().setWhereClause(null); getDetail_VO1().addWhereClause("header_id in (:1)"); getDetail_VO1().setWhereClauseParams(null); getDetail_VO1().setWhereClauseParam(0,headerID); getDetail_VO1().executeQuery(); } else{ //write down the message that there exist no more rows (custom message) } }
Kind regards
GYAN -
Properties of the file - Date of the last recorded
Hello.
I'm having trouble understanding the properties of the file, as "Last record Date" (DLS) and "Date modified" (MD).
I asked that the last of them, MD, has been changed whenever the content has changed. But Distribution lists must be updated also.
However, I have a file which has the DLS on 2007 and MD 2014 and the 'last impression"also is 2014.
How is that possible?
What has changed the date the content of the file was really the last?
I would be grateful if someone could help me understand this.
Thank you,
Nuno Roque
Modification date is when the file got changed on that hard drive. Even if you have never opened the file, just drag-and - drop it to drive flash (for an example) would last updated date change, because the file on this disk changed really.
Properties such as "Date of last recorded" and "date printed" are stored in the file itself, such as metadata and are updated no not by disk or operating system, but by the design (such as Word) program.
-
Dialog file save forgets the last record of consultation: (Windows XP)
Whenever opens the dialog "Save" now always default to the my documents instead of the selected folder the last time that a dialog box "Save the file" or "File Open" has been used. This problem affects most Microsoft applications (Notepad, Paint, Word, Excel, etc.) on my Windows XP SP3 System.It is interesting its opposite, the 'Open' dialog box only no by default the My Documents folder, unless the "Save file" dialog box will open in front of her. So, it seems that the "Save File" dialog is changing the 'active' in My Documents folder whenever it opens. Someone at - he of the clues as to why this can happen and how to get back to a normal behavior?It's time to time very waste to modify records whenever I have save or open a file and caused inadvertently save me files in the My Documents folder when I forget.I discovered later that the problem was caused by the objective document Management System, and it is part of their intended design 'big brother' to allows you to use their document management system to save the files. I was very pleased with him removing my system, which restored a normal behavior of the Save dialog window.
-
How to recover a database after you add a data since the last file backup.
How to recover a database after you add a data file to a tablspace existing since the last user managed backup.
PS: I am aware that the user managed backups are not used and RMAN is used these days.At the stage of the mount: select name from v$ datafile;
The last entry indicates a file named /xxx/xxx/.../UNNAMEDXXX.dbfNow
ALTER database create datafile ' / xxx/xxx/.../UNNAMEDXXX.dbf' as 'path_where_you_want_to_add_the_datafile ';
The name of the data file must match the name that added in production
This will create a data file to the required location.
Once the file has been created, you can continue with recovery.
-
Add a field to the last page of a document file only
Hello
Currently, I have a script which will add signature fields and the text on the first page of a document.
The script is required to specify the "last page" of the document and not the page number, because each file can vary depending on the number of pages.
The script is running in the batch on several files that are not open (usually 50 at a time).
If someone can advise please how to change the script, I'll be very grateful.
Create the field dynamically Date for signature of the employee field
var f = this.addField ("Todaydate", "text", 0,
[60, 54, 135, 75]) ;f.userName = "today's Date";
f.Value = 'auto update';
f.ReadOnly = true;
f.fillColor = color.ltGray;Create the signature dynamically for employee field
var f = this.addField ("mySignature", "signature", 0,
[120, 85, 330, 105]) ;f.setAction ("OnFocus", "var f = this.getField('Todaydate'); ("f.Value = util.printd (a/mm/yyyy", new Date() ");") ;
Change the third parameter of this.addField from 0 to this.numPages - 1
-
Lack the last record in second and so forth
When I record a stream to the FMS, press stop and then play my recorded stream, I seem to always miss the last second or two. What is a buffer problem? How can I solve this?Yes, that could be due to a problem of buffer. You want to ensure that the buffer is empty before you stop the publication. If you examine the code for the VideoRecord component, you will see an example of how to see the buffer. I find this also helps empty the stream (server side) before starting playback.
Maybe you are looking for
-
iTunes unexpectedly left using Remote
Often, almost every day, when I try to use the remote control to start a song on iTunes, iTunes ' ' farm in unexpected ways. This does not happen every time, it can run for 1 or 2 days, but too often. Anyone recognize this? And is there someone who c
-
Changing color to a dark gray background by default, do not see the buttons in gmail.
White pages shiny most of web sites hurt my eyes and I really enjoy making pages a gray color.After you change the preferences/content/color/background to a dark gray, I really like how everything seems particularly search pages, google calendar, gma
-
Display on Satellite C50-B919 problem
Dear Sir / Madam I have a problem in the configuration of my screen, I have a 8.1 Windows as OS on my Toshiba Satellite C50 B919 and I downloaded the drivers several times on your site and it did not work. How can I solve this problem? I can t connec
-
Impossible to uninstall Firefox HP Smart Web Printing.
I tried to uninstall HP Smart Web Printing from the Add/Remove panel, but the addon repeat myself that it will be uninstalled once restarted Firefox even after that I restart. Using Firefox 3.6 Beta 2. How to manually remove it? Message edited by Scr
-
Satellite P100 freezes a few minutes after the beginning
Hi all! Im having a little problem with my satellite. When I start my computer its TI all ok, but after 5-6 minutes, always do the same thing. The screen freezes and it is impossible to do antyhing. My computer is only 2 years old. My guess is that t