SQL to bring the last line and the just previous row in the table
Hi all
I have a table of orders, where a serial number can be booked with different number several times over several days.
Requirement is to bring the last order (based on the date of creation) number associated with this serial number and just previous order number and data in the format below.
Last order number | Serial number | Reservation location | No booking | Previous order number | Serial number | Reservation location | No booking |
It is essentially to generate the report that a reserved serial number with how many times with different orders and report must contain details of order two in a line.
Kind regards
You asked for the last line, and you have not provided data of the example or the expected results, so you get what you asked for.
You may be looking for data to be partitioned on another value, for example
SQL > ed
A written file afiedt.buf1. Select deptno, ename, empno, mgr, hiredate, prev_empno, prev_ename, prev_mgr, prev_hiredate
2 starting at)
3. Select deptno, ename, empno, mgr, hiredate
lag (empno) 4, over (partition by deptno arrested by hiredate) as prev_empno
lag (ename) 5, over (partition by deptno arrested by hiredate) as prev_ename
lag (mgr) 6, over (partition by deptno arrested by hiredate) as prev_mgr
lag (hiredate) 7, over (partition by deptno arrested by hiredate) as prev_hiredate
8, case when hiredate = max (hiredate) on (deptno partition) then 1 0 otherwise fine as max_hiredate
9 of PEM
10 )
11 * where max_hiredate = 1
12.DEPTNO EMPNO, ENAME MGR HIREDATE PREV_EMPNO PREV_ENAME PREV_MGR PREV_HIRED
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
10 7934 MILLER 23/01/1982 7782, 7839 KING 17/11/1981
20 7876 ADAMS 7788 23/05/1987 7788 SCOTT 7566 04/19/1987
30 7900 JAMES 7698 03/12/1981 7654 MARTIN 7698 28/09/1981
who is the last disc, by Department, as well as the previous within the same Department.
Tags: Database
Similar Questions
-
Hello
I played "Mahjong Trails" and in position # 3. He played last night and I just tried a few moments ago and I come in. Can you tell why?
I've struggled since Facebook has said that someone tried to enter in my accouant and they had me off facebook about 3 days. Who would have something to do with it?
Impatient of solve you this problem, because I REALLY don't like this game.
Thanks for taking care of this
hope that I broke all the rules. and I hope that I chose the right forum because I've NEVER done this before.
original title: GAME MAHJONG TRAILS Can t PLAY WHY
Hello Shirley,
This isn't a problem with MSE. You deal with Facebook on this (as hard as I know what to do).
There is an excellent chance that what has happened to your account either interfered with your game or was not completely fixed or there is something else wrong with your account or maybe the game. Your best bet is to start here: http://www.facebook.com/mahjongtrails#! /help/? section = applications_and_websites and see if you can get help any with the game or the other answers predefined or by searching. Then, would be to try general help: http://www.facebook.com/help/?topic=applications_and_websites#! /help/? tab = discussion where you can post questions about your problem. If possible, I try to uninstall and reinstall the game (even if it make you lose your points or your rankings) - or you can ask for help from their first that they are able to help. Or open a new facebook account in the meantime and see if you can download and play the game on this account. So not only will you be able to play, but you will know for sure, this isn't a problem with your computer, the game, your browser or malicious software. You can pretty well and nail down to a problem with the other account or installing the game on this account.
It is almost certainly a problem with Facebook and not your computer, malicious software or your browser. You need to deal with them on this subject. If you have the best technical support coordinated because of your recent problems, by all means to re-open the case, or get help that direct contact is all but impossible here trying.
I'm sorry, we can not help you more, but it's really a matter of Facebook and you need to deal with them to resolve the issue.
Good luck!
-
I bought Lightroom last year, and I just got a new computer yesterday. I guess I can download Lightroom on my new computer without buying it again, but how? Do I need to UN-download my old? Thank you!!
Hello
Please use the link below to download Lightroom 5:
Let us know if that helps.
Kind regards
Bani
-
SQL query for the table in the schema
Hi user;
Imagine that we have 10 schema in oracle db. I wonder all the name of the table as shcema A1. I want to find these tables name everything first (let us suppose schema A1 has 100,000 tables)
Then, I want to give select grant the user A for these 100,000 tables. I don't want to use grant any table. I just want to give A user to select right for tables (100,000) which is under schema A1. How can I do? Please give me some ideas or the path
Thank youAAAAA says:
Hi Nicholas.Its system of prod and I'm afraid to be confused :)
Yes, I understand very well you're scared, then why not you plan some tests in front on a dummy database?
Nicolas.
-
Difference between the current and previous row in a table
Hi all
I'm having a problem with the request. Some help please can me?
I need to get the difference between the previous row and current row in a table. I have a table, given as below.
TABLEX
================
Date items name
AAA 100 01 - SEP - 09
BBB 101 02 - SEP - 09
CCC 03-AUG-09 200
DDD 200 04 - SEP - 09
EEE 05-SEP-09 400
Now, I need to get an output like below...
Name Date of items Diff-items
AAA 01 / SEP / 09 100 0
BBB 1 101 02 - SEP - 09
CCC 03-AUG-09 200 99
DDD 04-SEP-09 200 0
EEE 05-SEP-09 400 200
Can someone help me write a query to get above the results?
Please let me know if you need more information.
Thank you very much in advance.
We use Oracle10G (10.2.0.1.0).
Thank you
AsifIf you have found your answer, mark it as answered. Thank you.
-
SQL - restructuring of the Table
Hello world
I hope that this is possible in Oracle. I need to restructure a followingly table. I appreciate all of your time.
With the help of 10 or 11 g
ResultPCP MEASURE SUCCESS TOTAL P001 A 2 3 P001 B 3 4 P001 C 4 5 P001 D 5 6 P001 E 6 7 P002 A 7 8 P002 B 8 9 P002 C 9 10 P002 D 10 11 P002 E 11 12 P003 C 12 13 P003 D 13 14
Published by: 788729 on October 26, 2011 13:42PCP A B C D E FLAG P001 2 3 4 5 6 SUCCESS P001 3 4 5 6 7 TOTAL P002 7 8 9 10 11 SUCCESS P002 8 9 10 11 12 TOTAL P003 0 0 12 13 0 SUCCESS P003 0 0 13 14 0 TOTAL
Hello
Assuming you are wanting to do using a query, you can go (using 10 G)...
select pcp, nvl(max(a),0) as a, nvl(max(b),0) as b, nvl(max(c),0) as c, nvl(max(d),0) as d, nvl(max(e),0) as e, flag from ( select pcp, case when measure = 'A' then success end as a, case when measure = 'B' then success end as b, case when measure = 'C' then success end as c, case when measure = 'D' then success end as d, case when measure = 'E' then success end as e, 'SUCCESS' as flag from temptable union all select pcp, case when measure = 'A' then total end as a, case when measure = 'B' then total end as b, case when measure = 'C' then total end as c, case when measure = 'D' then total end as d, case when measure = 'E' then total end as e, 'TOTAL' as flag from temptable ) group by pcp, flag order by pcp, flag
Hope this helps,
MarkPublished by: user455268 on October 26, 2011 16:15
-
How to add data to the table changed in sql developer at Apex and vice versa
Hello
I had tables of database with sql developer. But now, I have modified the database (new tables added + changed the data in the tables). However, in the Apex, I the old database. Is it possible to get the new Apex database with the data of the table changed so this database in both places (sql and apex developer) is exactly the same... Also the other way around.
Thank you
The database schema that contains the tables, is it associated with the workspace even you are searching through the APEX product t development? Why I'm asking is, if they are the same schema, the tables that you MODIFIED should be appear in the sql for APEX workshop part. Now reports and forms will NOT see the changes (unless you have actually added or updated definitions for column).
Can you explain what exactly you were doing the SQL Developer to the tables in your schema?
Thank you
Tony Miller
Los Alamos, NM -
How can I pass a condition of the table in the sql statement?
For example, in the table in the COND Varchar2 column (200) there is the value ' VAR > 10'.
| COND |
|' VAR > 10' |
where VAR is the name of the table column. I would like to make statement CASE WHEN VAR > 10 AND 0... I tried with as subquery
WHEN BOX (SELECT COND FROM TABLE WHERE...) THEN 0, but it does not work.
Hello
You can do this by using dynamic SQL.
that is to say:
declare v_stm varchar2(4000); v_cond varchar2(100); v_result integer; begin select cond into v_cond from yourtable where a=1; v_stm := 'select case when '||v_cond||' then 0 ...'; -- dynamic sql execute immediate v_stm into v_result; end; /
Remember that, in general, dynamic SQL has a performance degradation that SQL static and should be avoided when possible.
Storage condition or the SQL statements in the tables is not a good practice.
Kind regards.
Alberto
-
Download of huge external file to the table
Hello
I need to download a file (.txt) that contains about 200000 lines and 7 MB of data at my table using PL/SQL to manupulate it later. (.txt) file contains columns of type number and text.
First, I declare the data (.txt file) by using the object "file - browse."
Secondly, when I push the button submit, contains a (.txt) file will be inserted in my database table (my_table)
the last one, I'll use my_table to use insert, select, update of functions etc.
It takes about 20 minutes to download above file size in (my_table) with the classical upload method.
which is the best way to download size file to programmathicly (my_table)?
What type of procedure (s) should I write for best performance?
Thank you...
NILE - Istanbul...Hate to say it, but I am at a loss here. I'm sorry.
Tyler
-
Shrink the table, rebuild the index?
I need to reduce some very large tables after the removal of lines and I want to validate the script to run. I was thinking something like this:
run_deleting_process;
change the movement line of table my_tableI enable;
ALTER table my_table retractable space WATERFALL;
change the movement line of table my_tableI disable;
I need to rebuild the index after that?, or if I rebuild the markings, can I delete clause CASCADE of the command? It is recommended to run utltrp.sql after shrink the table?, maybe some dependent object needs to be recompiled after the reduction of a table?
The database version is 11.1.0.7 and documentation does not specify that the index rebuild is required, but I realized it is a desition normall when the narrowing of the tables.
Thank youNo there is no rebuild the index after shrinkage. And if you use "cascade", your index will be supported. You do very well.
Visit this link as well.
http://www.orafaq.com/Forum/t/137522/2/
-
Create the table using check constraints
I am trying to create a table with the following sql statement.
CREATE TABLE suppliers
(
supplier_id NULL NUMERIC (4).
supplier_name NULL VARCHAR2 (50).
Date1 DATE NULL,.
date2 DATE NULL CONSTRAINT CHECK check_date (date1 > date2)
);
I am gettign the following error
"ORA-02438: column check constraint cannot reference other columns.
How can I get this red using a trigger.
Help, pleaseSimply, you missed a comma after your last column and constraint.
ME_XE?CREATE TABLE suppliers 2 ( 3 supplier_id NUMERIC(4) NULL , 4 supplier_name VARCHAR2(50) NULL , 5 date1 DATE NULL , 6 date2 DATE NULL , 7 CONSTRAINT check_date CHECK (date1 > date2) 8 ); Table created. Elapsed: 00:00:00.04
-
I would like to change the array1 table to create array3 by copying the first line and insert then three rows with the same data element.
and the same operation for the second row. Thank you
-
How to choose half of a title to appear as title 1 in the Table of contents?
I am creating a document containing several job descriptions and want to have a hyperlink in a Table of contents description of each individual work. The way securities are in the format looks like this: "profile Description: President. The only part of the title I want to appear in the Table of contents is '' President. '' How can I select the part of the title to post a link in the table of contents? I've highlighted the portion of the line I want to appear as the title 1 but Word (2010) insists on the selection of the entire line and not just the part that I chose to be Heading 1. I know that I could drop the word 'Président' to another line, but it's not the look I want. I think I should perhaps use a bookmark or do something with the field but am way over my head on this one. I only know some of the basics and the terms bookmark and the field are new for me and quite mysterious. Any help would be appreciated, but I am a novice and must be crossed it work with no baby.
KathieYZ
Ok. I assume that you do this in Word?
If so, then the word is part of office (for which there are specific forums on this site) and no windows.
Click on the Forums link at the top of this window, choose the desktop, and then select the version of Office you are using and choose the word.
Post your question here. -
identify the tables that are affected by a transaction
Hi guys,.
I am running version:
Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE Production 11.2.0.3.0
AMT for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
Is it possible to identify the SQL code or the tables involved in a transaction by looking at the transaction$ v?Just wrote a small application, but can't test it in my DB... Just check it...
Basically CREATE all the views will provide some information.SELECT t.ses_addr, s.sid, p.object_id, D.OBJECT_NAME,s.command FROM v$transaction t, v$session s, V$locked_object p, dba_objects d WHERE t.ses_addr = s.saddr AND p.session_id = s.sid AND d.object_id = p.object_id;
The command column is a code displays what kind of operation is being currently... the explanation of the code can be mentioned in the documentation:
http://docs.Oracle.com/CD/B19306_01/server.102/b14237/dynviews_2088.htm
See you soon,.
Manik. -
Not all cells in the table is formatted but just the first.
var doc = app.activeDocument,
_pages = doc.pages, i, j, k, l.
_textframes, _tables _row, _cell, rownum;
for (i = 0; i < _pages.length; i ++) {}
_tables = _pages.item (i). Tables;
for (j = 0; j < _tables.length; j ++) {}
_Row = _tables.item (i) Rows;
rowlen = _row.length;
for (k = 0; k < _row.length; k ++) {}
_cell = _row.item (i) .cells.
for (l = 0; l < _cell.length; l ++) {}
_cell. Item (i) .appliedCellStyle = "CellA ';
_cell. Item (i).paragraphs.everyItem () .appliedParagraphStyle = 'ParA ';
}
}
}
}
Hi, I'm stuck in this code. I want to format all the cells of the table, but using the code above only the first cell of the first row is updated with the format. The other problem is that, in all the lines, it is a cell unique couting. "CellA" and 'ParA' is the cell styles and paragraph styles I made in my pc. I'm relatively new to indesign scripting and try to learn something new.
Hello
1. There is no property, '.table' for 'page' pages.item (i) .tables returns error;
2 Javascript is case sensitive so watch start a property with a small letter names ("Tables" are false);
3. There is no need to browse the pages, tables, lines and cells - just use . everyItem().
so
app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().appliedCellStyle = "CellA"; app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().paragraphs.everyItem().appliedParagraphStyle = "ParA";
should work.
Jarek
Maybe you are looking for
-
Firefox 8 supports norton 360 Prime Minister
Norton safe identity does not work
-
Satellite P10 switch randomly between battery and AC
I have a satellite P10 who had some problems of strange power for about a year now. My laptop switch to the power of the battery even when it is plugged. I will then either use the computer until the battery runs out and turned it off or Hibernate in
-
Graphics Envy of HP HP Envy of upgrade - 700-74
I want to buy a card EVGA GeForce GTX 750 TI 2 GB GDDR5 PCI Express 3.0 Graphics, I do not know if I have enough space inside my case or if my CPU can handle, thank you. Graphics link - http://www.bestbuy.com/site/evga-geforce-gtx-750-ti-2gb-gddr5-p
-
Removal of old versions of software
Sometimes I get notifications of updates to earlier versions of the software, but the updates always seem to fail. This morning there were updates for 2015 of PS and bridge CC - which I also have the latest version of the.On the Adobe support page u
-
I downloaded and installed LR and PS and they throw very well but when I try to change an ARW raw file all I get is a blue screen. Can anyone help?