Compare and get the number of days since the same date field
HelloI need to get the results in days when comparing the same field, date
For example,.
Primary_key_field Date_field
100000002 1 January 10
100000004 February 1st, 10
100000005 30 April 10
100000006 April 18, 10
100000007 29 April 10
100000008 May 1st, 10
extract the first two date_field records based on the primary_key_field. (January 1, 2010 and February 1, 2010) and compare and find the difference and who appear in number of days, the same fetch two disks and do the same math... How can I achieve this... is it possible to make the SQL thro? Please help me solve this problem...
Thank you and best regards,
KBG.
This is the query using functions oracle Analytics
Primary_key_field Date_field
100000002 1 January 10
100000004 February 1st, 10
100000005 30 April 10
100000006 April 18, 10
100000007 29 April 10
100000008 May 1st, 10
Select rn, date_field, next, next - date_field "Diff".
de)
ROW_NUMBER() SELECT over (ORDER BY primary_key_field) rn,
date_field, LEAD (date_field) OVER (ORDER BY date_field) next
FROM table_name)
/
Tags: Database
Similar Questions
-
photos has not been loaded for weeks (usually the browser chrome on PC windows at work). I tried now on some other computers and get the same error message and I report every time. is there anything I can do or just wait for someone to fix it?
If you want any help here, you'll have to tell us what the error message.
Which report you errors to?
-
My Acrobat Pro 11 appears msg 16 "Please uninstall and reinstall" what I've done 4 times already, so I run it and get the same msg. I spent 4 hours chatting with Adobe engineers who have not helped.
Hello
Sorry for the delay in reply!
Please run as administrator (right click on the Acrobat icon & then run as administrator).
You can check error: 16
Acrobat X Pro: Configuration error when viewing PDF files
The first step should help resolve the issue.
Let us know if this helps!
-
Error code 204 trying to download CC on new laptop (2nd computer) it will not download and receive the error code 204. I tried turn off anti-virus and firewall and get the same error code. How do we install CC?
Please ignore. I disabled the anti-malware and the app is trying to install.
Thank you
-
Compare and get the data in the tables (see post for details)
I have two tables TableA and TableB. I struggle to write a query to get the dates of TableB (instead of TableA dates) where TableA dates don't coincide with the tableB (beginning and end).
Example 1: For account A1234,.
TableA got 2 rows 1/31/2014-3/3/2014 (which corresponds to TableB row), but TableA got another rank 31/01/2014 - 31/01/2014 that corresponds with the date of TableB Begin. In this case, I'm looking for output as below,
Use TableB start and end date and combine number two rows from TableA for this account
ACCOUNT TableB_BEGIN TableB_END AMOUNT A1234 31/01/2014 03/03/2014 100.0000000000 Example 2: For the B7777 account.
TableA end date aligns with the end dates of TableB for this account, in this case I want out put as,.
Use TableB start and end date and get the amount of TableA
ACCOUNT TableB_BEGIN TableB_END AMOUNT B7777 05/04/2013 06/05/2013 200.0000000000 Example 3: On behalf of D5555,.
Even a TableA line corresponds with TableA, there are two other rows in TableA matching start date with TableA and correspondence with the end date with TableA, in this case, that I put as,.
Use TableB start and end date and combine number three rows from TableA for this account.
ACCOUNT TableB_BEGIN TableB_END AMOUNT D5555 08/08/2014 10/09/2014 1100.0000000000 Example 4: To account E6666.
Table corresponds to a row with TableB and no additional lines in TableA, just display the data in A table
Tables and data:
create table TableA ( Account varchar2(10) not null, Begin date not null, End date not null, Amount number(19,10) not null ) ; create table TableB ( Account varchar2(10) not null, Begin date not null, End date not null, Amount number(19,10) not null ) ; TableA Data: insert into tablea (ACCOUNT, BEGIN, END, AMOUNT) values ('A1234', to_date('31-01-2014', 'dd-mm-yyyy'), to_date('31-01-2014', 'dd-mm-yyyy'), 0.0000000000); insert into tablea (ACCOUNT, BEGIN, END, AMOUNT) values ('A1234', to_date('31-01-2014', 'dd-mm-yyyy'), to_date('03-03-2014', 'dd-mm-yyyy'), 100.0000000000); insert into tablea (ACCOUNT, BEGIN, END, AMOUNT) values ('B7777', to_date('18-04-2013', 'dd-mm-yyyy'), to_date('06-05-2013', 'dd-mm-yyyy'), 120.0000000000); insert into tablea (ACCOUNT, BEGIN, END, AMOUNT) values ('C6666', to_date('25-06-2014', 'dd-mm-yyyy'), to_date('08-07-2014', 'dd-mm-yyyy'), 10.0000000000); insert into tablea (ACCOUNT, BEGIN, END, AMOUNT) values ('D5555', to_date('08-08-2014', 'dd-mm-yyyy'), to_date('16-08-2014', 'dd-mm-yyyy'), 1000.0000000000); insert into tablea (ACCOUNT, BEGIN, END, AMOUNT) values ('D5555', to_date('08-08-2014', 'dd-mm-yyyy'), to_date('10-09-2014', 'dd-mm-yyyy'), 0.0000000000); insert into tablea (ACCOUNT, BEGIN, END, AMOUNT) values ('D5555', to_date('16-08-2014', 'dd-mm-yyyy'), to_date('10-09-2014', 'dd-mm-yyyy'), 100.0000000000); insert into tablea (ACCOUNT, BEGIN, END, AMOUNT) values ('E6666', to_date('01-01-2014', 'dd-mm-yyyy'), to_date('01-02-2014', 'dd-mm-yyyy'), 100.0000000000); TableB Data: insert into tableb (ACCOUNT, BEGIN, END, AMOUNT) values ('A1234', to_date('31-01-2014', 'dd-mm-yyyy'), to_date('03-03-2014', 'dd-mm-yyyy'), 100.0000000000); insert into tableb (ACCOUNT, BEGIN, END, AMOUNT) values ('B7777', to_date('05-04-2013', 'dd-mm-yyyy'), to_date('06-05-2013', 'dd-mm-yyyy'), 200.0000000000); insert into tableb (ACCOUNT, BEGIN, END, AMOUNT) values ('C6666', to_date('06-06-2014', 'dd-mm-yyyy'), to_date('08-07-2014', 'dd-mm-yyyy'), 10.0000000000); insert into tableb (ACCOUNT, BEGIN, END, AMOUNT) values ('D5555', to_date('08-08-2014', 'dd-mm-yyyy'), to_date('10-09-2014', 'dd-mm-yyyy'), 1100.0000000000); insert into tableb (ACCOUNT, BEGIN, END, AMOUNT) values ('E6666', to_date('01-01-2014', 'dd-mm-yyyy'), to_date('01-02-2014', 'dd-mm-yyyy'), 100.0000000000); SELECT A.ACCOUNT, A.BEGIN, A.END, A.AMOUNT, B.ACCOUNT, B.BEGIN, B.END, B.AMOUNT FROM TABLEA A LEFT JOIN TABLEB B ON A.ACCOUNT = B.ACCOUNT
Hello
SeshuGiri wrote:
Hi Frank,.
Your query/solution works very well, but I forgot to mention something in the first post...
Please insert these additional lines and try the request again.
TableA Additional lines:
- Insert into TABLEA (ACCOUNT, BEGIN, END, QUANTITY)
- values ('F9999', to_date (January 2, 2014 ',' dd-mm-yyyy ""), to_date (3 January 2014 ', 'dd-mm-yyyy'), 999.0000000000);
- Insert into TABLEA (ACCOUNT, BEGIN, END, QUANTITY)
- values ('A1234', to_date (March 3, 2014 ',' dd-mm-yyyy ""), to_date (4 March 2014 ', 'dd-mm-yyyy'), 999.0000000000);
TableB Additional lines:
- Insert into TABLEb (ACCOUNT, BEGIN, END, QUANTITY)
- values ('A1234', to_date (March 3, 2014 ',' dd-mm-yyyy ""), to_date (4 March 2014 ', 'dd-mm-yyyy'), 999.0000000000);
Question 1:
The table has a rows for A1234 account (i.e. the time period different than the ranks for the same account)
one is A1234 31/01/2014-03/03/2014, A1234 03/03/2014-03/04/2014
Your query that returns two rows for A1234 account (which is what I want), but the amount is messed up.
ACCOUNT BEGIN END TOTAL_AMOUNT 1 A1234 31/01/2014 03/03/2014 1100 2 A1234 03/03/2014 03/04/2014 1100 Except:
ACCOUNT BEGIN END TOTAL_AMOUNT 1 A1234 31/01/2014 03/03/2014 101 2 A1234 03/03/2014 03/04/2014 999 Question 2:
In some cases TableA will have an account (F9999), but the TableB don't. I can just this line by making the Left Join right join?
I don't get the results with additional data. I get 1099 for two lines where account = 'A1234 '. I get 1100 as the amount on the line with the account = "D5555. You did it other changes to data?
Except:
ACCOUNT BEGIN END TOTAL_AMOUNT 1 A1234 31/01/2014 03/03/2014 101 2 A1234 03/03/2014 03/04/2014 999 Still, I don't see why you want to 101 for the amount of the first row. Why not 100?
How can you know which rows from tablea should get attached to what rows from tableb, when the account is not unique?
Maybe you want something like this:
SELECT a.account
b.begin
b.end
SUM (a.amount) AS total_amount
FROM tablea a
ON a.account = b.account JOIN tableb B
AND a.begin BETWEEN b.begin
AND b.end
AND a.end BETWEEN b.begin
AND b.end
GROUP OF a.account, b.begin, b.end
ORDER BY a.account
;
but I guess just to your needs, and guessing is not a very good or reliable way to solve problems.
Question 2:
In some cases TableA will have an account (F9999), but the TableB don't. I can just this line by making the Left Join right join?
Yes, it looks that you want an outer join. What happened when you tried? As always, post your code, the exact results you want from the given sample data, as well as an explanation of how you get these results from these data.
-
I tried to install a new copy of Lightroom 6 and he says I have Vista OS but my OS is Windows 7. I tried to restart the computer and reload the software but get the same error. Any suggestions?
See the link below:
-
What does Error Message 43 on a MacPro?
Your Mac or missing system files or the hard drive is damaged.
If your Mac is running v10.7 Lion or later, start your Mac while pressing the command + R keys.
From there, you should be able to access the building in utilities to check and repair the boot and OS X restore disk using OS X Recovery.
-
How to handle multiple formats of date to the same date field in SQL * Loader
Dear all,
I have a requirement where I need to get data from a text file and even insert into the oracle table.
I'm using SQL * Loader to fill data from the text file in my table.
The file has an area where I expect to date data date in different formats, such as MON/dd/yyyy mon/dd/yyyy mon/dd/yyyy, dd/mm/yyyy, DD/month/yyyy.
When you use SQL * Loader, I can see loading fails for records where we have formats such as LUN/jj/aaaa, Mon/dd/yyyy, DD/month/yyyy.
Is it possible in SQL * Loader where we can mention all these date formats so that data from that date should go smoothly in the underlying date column in the table.
Receive your answer on that.
Thank you
Madhu K.I think following could be the solution to your problem:
Suppose if you have data from four different date formats, you need to load the data into four different tables by running SQL * Loader four times and each time specify other date format in the control file whose data to load, and then at the end, merge data from these four different tables using the UNION clause.
Elya
-
Parsing XML and get the required data only using PLSQL
Hi friends,
I have a XML data
< MAJOR_LINE >
< LINEID > 143424538 < / LINEID >
nom_element < ITEMNAME > = < / ITEMNAME >
< > 78245 ITEMPATH < / ITEMPATH >
< QUANTITY > 10 < / QUANTITY >
< MINORLINE >
< LINEID > 143424799 < / LINEID >
TCC_ITEM_NAME < ITEMNAME > < / ITEMNAME >
< > 78245 ITEMPATH < / ITEMPATH >
< QUANTITY > 10 < / QUANTITY >
< MINORLINE LINEID = "123456_line_id" xmlns = "xxyyzz" >
< message > < / message >
< status > < / status >
< covered_Product_line_id > '123_coveredProductLineID '.
< / covered_Product_line_id >
< itemName > < / itemName >
< quantity > < / quantity >
"< service lineId ="456_service_line_id">."
"< covered_Product_line_id >"123_coveredProductLineID"
< / covered_Product_line_id >
< productAttributes / >
< itemType > < / itemType >
< itemPath > < / itemPath >
< coveredProducts childProductLineId = "" / > "
< / coveredProducts >
< parentCoverage / >
< / service >
< / MINORLINE >
< / MINORLINE >
< / MAJOR_LINE >
I want to extract only the Covered_product_line_id and the Service_line_id of the above XML format, these data can come from any where in the xml file and the xml can be any length.
First we need to find the covered_product_line_id and the service_line_id associated with line_id, (as I pointed out in bold) here only a single pair i showed, but it can be in any number. (Note the line_id is inside the tag).
#PLSQL
Help, please.
Thanks in advance
Hey Odie,
Me do string literal too long error:
Select x.*
from xmltable)
XmlNamespaces(default ')
, ' for $i in //serviceLine
, $j in $i / coveredProduct
Returns the element r {}
$i / lineId
, $j/childProductLineId
}'
from xmltype (')
45146937 N20 1 63090598 CON-S 1 SNT UCS - IOM 342544294 N20-FW012 342544295 342544294 UCS-IOM2 1 N20-C6508-UPG: 45146937 CON-S 1 SNT 342544295 N20-FW012 1 N20-C6508-UPG: 45146937 CON-SN 1 SNT 342544296 FET - 10G 16 N20-C6508 - UPG:U SC EXPERIENCE 342544297 UCSB-5108-PKG-FW 1 N20-C6508-UPXPANSION O 342544298 N20-CBLKP 2 N20-C6508 - UPG:0 - CBLKP 342544299 N01-UAC1 1 N20-C6508 - UPG:N01 - UAC1 342544300 N20-CBLKI 1 N20-C6508 - UPG:U HC EXPANSION OPT: N20-CBLKI 342544301 N20-FAN5 8 N20-C6508 - UPG:U HC EXPANSION OPT: N20-FAN5 342544302 N20-CBLKB1 6 N20-C6508-UPG-CBLKB1 342544303 N20 - CAK 1 N20-C6508-OPT: N20 - CAK 342544304 UCSB-B420-M3-D 1 N20-C6508-UP-B420-M3-D 63090594 CON-SNT-B420M3D 1 SNT UCS-UC-E5-4617 342544305 UCS-ML-1X324RY-A 342544306 342544305 UCS-UC-E5-4617 2 N20-C6508 - UPG:PU - E5-4617 342544304 CON-SNT-B420M3D 1 SNT 342544306 UCSRY-A 2 N20-C624RY-A 342544304 CON-SNT-B420M3D 1 SNT 342544307 UCS0MS 1 N FIO-1600MS 63090595 CON-SNT-FIOB16MS 1 SNT 342544308 N2KD 4 N20-C6LKD 342544309 UCSB-HS-01-EP 2 N20-C65B-HS-01-EP 342544310 N1K-VSG-UCS-BUN 1 N20-C6508 - UPG:U-BLA1K-VSG-UCS-BUN 342544311 VSG-VLEM-UCS-1 1 N20-C6508 - UPG:U BLN1K BUN: VSG-VLEM-UCS-1 63090596 CON-SAU-VSGUCS 1 SAU 342544312 N1K-VLEM-UCS-1 1 N20-C6508CS-BUN: VMW N-UCS-1 63090597 CON-SAU-VLEMUCS 1 SAU 342544313 UCSB-ACDV 2 N20ACDV 342544314 R2XX-DMYMPWRCORD 2 PWRCORD N20 - C6 ')
columns for the ordinalite seq_id
, path number child_product_line_id "childProductLineId".
, service_line_id number path "lineId.
) x ;
-
Compare and update the same column
Hello
SQL & gt; Select * from
version of v$.
BANNER
-----
Oracle Database 10g Express
Edition Release 10.2.0.1.0 - product
PL/SQL Release 10.2.0.1.0-
Production
CORE 10.2.0.1.0 Production
AMT for 32-bit Windows:
Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0-
Production
I'm having a problem to update the column in a Table...
What I'm trying to do is... .compare 2 column and then update one column by report...
Table 1 name: TEST1 _
Bq. LNID------NEW_AN8------OLD_AN8------OLD_DESC------2--------123002------100001------C2370------125846------CS24 100001------123024------100028------C2392------125868------CS25 100028------123025------C2393 100036------125869------100036 123026 CS26------100116------C2394------125870------100116------CS
_ Test2
SZAN8 SZAN82 SZAN86 SZAT1
123 002 100 001 100 001 C
125 846 CS 100 001 100 001
123 024 100 028 100 028 C
125 868 100 028 100 028 CS
125 869 100 036 100 036 CS
123 025 100 036 100 036 C
125 870 CS 100 116 100 116
123 026 100 116 100 116 C
I wanted to update the table SZAN82 of TEST2... based on the value of SZAT1...
I shud be able to choose the record type CS first, then the C type registration and the value of SZAN82 and check if it is present in the TEST1 table if she then I shud update the 82 value updated.
UPDATE LPLSCHEMA. LPL_F0101Z2_CUSTOMER C SET (SZAN82) =
(SELECT NEW_AN8 FROM LPL_CROSS_CUSTOMER B, LPL_F0101Z2_CUSTOMER C WHERE 'C.SZAT1 =' CS AND B.OLD_DESC = 'CS' and C.szan82 = B.old_an8);
I tried like tis... I received a request to void error more than a ranks...
Thanks in advance!
Ananda
Published by: Ananda on January 2, 2009 18:30
Published by: Ananda on January 2, 2009 18:30
Published by: Ananda on January 2, 2009 18:34
Published by: Ananda on January 2, 2009 18:37UPDATE LPLSCHEMA.LPL_F0101Z2_CUSTOMER C SET SZAN82 = ( SELECT NEW_AN8 FROM LPL_CROSS_CUSTOMER B WHERE C.SZAT1='CS' AND B.OLD_DESC='CS' AND C.szan82=B.old_an8 ) WHERE EXISTS ( SELECT 1 FROM LPL_CROSS_CUSTOMER B WHERE C.SZAT1='CS' AND B.OLD_DESC='CS' AND C.szan82=B.old_an8 );
SY.
-
nothing to add
Hello!
It seems that you do not use the latest version of Firefox. Please update and try again: http://www.mozilla.org/firefox
-
I get windows did not start and each time that I reboot I get the same thing.
* Original title: Windows7
O my pc displays a boot device error so I put in a disk hard new1tb and reinstalled Windows 7 and install goes ok just a little slow, but after the installation is completed after the first reboot I get windows did not start and evry time I reboot I get the same thing tried several hard drives and get the same error not sure of the material cause I can load in the bios very well any help would be great
In addition:
Clear CMOS - 3 ways to clear the CMOS - reset the BIOS
The setup of the BIOS or UEFI firmware, search for UEFI settings so that you can follow special steps to install UEFI below. Also set SATA controller on AHCI, hard drive, all on first start (or if UEFI Boot Manager WIndows).
Then just follow these steps for a clean reinstall Windows 7 making sure to remove all partitions up to unallocated space to make it cleaner. Follow special steps if you have a UEFI BIOS, which will have a system partition EFI in Managment of disk instead of reserved system (MBR) and make sure that the SATA controller is set to AHCI.
Other important to overcome optmizations install them hedges here to resolve the failures of Windows Installation 7
-
I get the same error message and cannot open a PDF file
I have a link to an application that I am trying to download and complete. By default the link my browser to open. what he does normally. However, this document was a mistake. He said that I need the latest version of Adobe. So I downloaded the application, open the PDF file in the app and get the same error message. Help!
Hello
You see the following error message when you open the PDF document?
If so, it is a special type of PDF created with Adobe LiveCycle Designer form called "Dynamic XFA".
Acrobat Reader mobile apps (for iOS, Android, Windows Phone) do not support XFA forms.
Please download the PDF document on your Windows or Mac computer and open it with Acrobat Reader DC desktop version.
Please let us know if you have a different problem.
Sorry for the inconvenience.
-
Query to select other records and then the same in 2 tables
Dear all,
My database is 10 gr 2 and OS is Linux.
I have 2 tables with the same fields and almost the same data. There are just a few different lines in table 1 and table 2 that do not match each other.
I need to select these non-matching rows in both tables in a single request.
Kindly help on that.
Best regards, ImranYou have at LEAST two ways!
(SELECT * FROM table_A minus SELECT * FROM table_B) union all (SELECT * FROM table_B minus SELECT * FROM table_A) /
For example:
SQL> create table table_a (col_1 number, col_2 varchar2(5)); Table created. SQL> create table table_b (col_1 number, col_2 varchar2(5)); Table created. SQL> insert into table_a values (1,'A'); 1 row created. SQL> insert into table_a values (2,'B'); 1 row created. SQL> insert into table_b values (1,'X'); 1 row created. SQL> insert into table_b values (2,'Z'); 1 row created. SQL> insert into table_a values (3,'C'); 1 row created. SQL> insert into table_b values (3,'C'); 1 row created. SQL> commit; Commit complete. SQL> SQL> select * from table_a minus select * from table_b 2 union all 3 select * from table_b minus select * from table_a 4 / COL_1 COL_2 ---------- ----- 1 X 2 Z SQL> (select * from table_a minus select * from table_b) 2 union all 3 (select * from table_b minus select * from table_a) 4 / COL_1 COL_2 ---------- ----- 1 A 2 B 1 X 2 Z SQL>
Hemant K Collette
-
Ligtroom 6 Better, I will describe my problem once right 1. always after 4 weeks, I get the message "trial version expired Ligtroom 6a 2. you will be asked to fill out my license number 3. After completing the restart and get the message "error 16". 4. all again manager install Adobe again and install this once again repeated problem Ligtroom each month can ensure that this stops my version is a purchased official version Now repeat the problem after only 4-5 days! Caveat! I'm not a computer specialist are not too complicated solution Since this is an open forum, not Adobe support... you must contact Adobe personnel to help
Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">===>
Don't forget to stay signed with your Adobe ID before accessing the link below
Creative cloud support (all creative cloud customer service problems)
Maybe you are looking for
-
How to download a song on iTunes?
I want to download a song on iTunes, but I don't know how... If anyone knows please comment. It would be greatly appreciated!
-
Pavilion g6: graphics card option
Hello I use the computer hp laptop pavilion g6 with windows OS. I would like to add graphics card on my laptop. Can I add a graphics card with the laptop, is it possible to add possibe.
-
Portege Z930 - black dots on his gray paint
Hello. My name is Nicolas. I have a few black dots on my Ultrabook, seems to be a default factory or struct.I would like to know why is it caused by, because it looks like bubbles and this means that they could not be caused by a success. They have v
-
analyzes a document to my PC in read/write format
How to scan a document from my printer to my PC in read/write format?
-
Maximum number of files that a folder can contain
Title says it all. What is the practical limit to the number of files that can contain a single folder? These would all be tiny files, usually less than 20K, I'm looking for emotional limit of Windows, rather than the clear disk space limit. This is