Query for the extraction of data not available
mst_company1company_year company_rating
2001 A
AA 2004
2009B
2010 C
2011 B +.
2020
For the table above, mst_company1
Years, from 2001 to 2020 and the coast for years are as shown above.
There are few who do not have any side
Now in the output, I need the following:
output:-
Quote of the year
2001 A
2002 NR
AA 2004
2005 NR
2009B
2010 C
2011 B +.
NR OF 2012
In the output, the years that have a side must be displayed along with the next
consecutive year should also be displayed with the rating of NR (No Rating).
For example, 2001 a rating at least one, so that the next data to be displayed must be 2002 and must wear
NR, 2003 should not be visible, and then 2004 that has a rating AA should be displayed
and then 2005 side NR should appear, 2006 will not be displayed.
Should which application I write to achieve?
Hello
Lol the query for your requirments is:
WITH got_next_year AS
(
SELECT company_year
, LEAD (company_year, 1, company_year + 2)
OVER (ORDER BY company_year) AS next_year
FROM mst_company1
)
SELECT company_year
, company_rating
FROM mst_company1
--
UNION ALL
--
SELECT next_year AS company_year
, 'NR' AS company_rating
FROM got_next_year
WHERE next_year > company_year + 1
--
ORDER BY company_year
;
Tags: Database
Similar Questions
-
Hello
I have a ZIP column which is the Varchar2 data type, it has values such as 2345, 09485, 10900, 07110, 06534.
I have to go look up records from the range of values for the ZIP column as between 00000 and 07500.
Could you give a logic.
Thank you.
Hello
I think you can use the following code:
SELECT T.*
OF
t WHERE the to_number (ZIP) between TO_NUMBER('0000') and TO_NUMBER('07500')
;
CGomes
-
SQL query for the set of data rows not values
Hello!
I use Oracle 10 g (10.2.0.1.0) and I need help to solve this difficult task. I have a huge table with more than 145000 records and I shows you only a sample of it:
ID TEAMNAME_EN DT TEAMNAME_EN HPROB AM APROB FT
324813 31/8 / 2012 DEN HAAG GRONINGEN 1.90 3.30 3.10 2
324823 31/8 / 2012 MAINZ GREUTHER FÜRTH 1.75 3.25 3.65 2
324805 31/8 / 2012 GAZELEC DIJON 1.60 3.15 4.75 1
324810 31/8 / 2012 ÖREBRO DJURGÅRDEN 2.80 3.25 2 2.05
324795 31/8 / 2012 FC KÖLN COTTBUS 1.85 3.20 3.35 2
324837 31/8 / 2012 PORTLAND WOOD COLORADO RAPIDS 2,00 3.20 2.95 1
324828 31/8 / 2012 DROGHEDA UNITED, DUNDALK 1.45 3.65 5.25 1
324827 31/8 / 2012 CORK CITY SHAMROCK ROVERS 3,30 3,80 1.70 2
324833 31/8 / 2012 BARUERI ASA 2.45 3.20 1-2.30
324798 31/8 / 2012 GENÇLERBIRLIGI ORDUSPOR'A 2.00 3,10 X 3.00
324814 31/8 / 2012 ALMERE CITY FC OSS 1,80 3,50 3,20 2
324830 31/8 / 2012 CRICIÚMA BRAGANTINO 1.25 4.35 1 8.00
324820 31/8 / 2012 VOLENDAM FC EINDHOVEN 1.80 3.25 3.45 1
324818 31/8 / 2012 MVV MAASTRICHT TELSTAR 1.40 4.00 X 5.25
324819 31/8 / 2012 DORDRECHT VEENDAM 1.80 3.25 3.45 1
324834 31/8 / 2012 CEARÁ GUARATINGUETÁ 1.40 3.85 X 5.50
If this table consists of
dates
teams (hometeam, awayteam)
numbers for homewin, shoot, awaywin probability
and the final result as 1, X, 2
What I want is a sql query that returns to me for each hometeam, awayteam and (if possible in a single line)
all documents of the hometeam which had the same number of prior probability. For example:
CEARÁ (last line), I would like to the sql to show me all the records of CEARA who had _1.40 3.85 or 5.50_ in each of the three issues of probability, BUT the problem is that I do want separate lines... I can do so far is to calculate a sum of House probability, probability of drawing, close probability for each team but the same records are calculated again in each game of probability!
This means if CEARÁ has 1.40-3.85-5.50 in the past it will return me this line only once, and not 3 times (one for each set of probability)
I hope that I've done my duty,
Thank you for your time and lights
N. SaridakisIs that what you are looking for:
select hometeam, awayteam, hw, hd, hl from (select hometeam, awayteam, ft, SUM(CASE ft WHEN '1' THEN 1 ELSE 0 END) OVER (PARTITION BY hometeam) hw, SUM(CASE ft WHEN 'X' THEN 1 ELSE 0 END) OVER (PARTITION BY hometeam) hd, SUM(CASE ft WHEN '2' THEN 1 ELSE 0 END) OVER (PARTITION BY hometeam) hl from plays) where ft is null
-
Hello
I have a column called period and there dates with all Fridays in it until the end of October. I want to list all the dates only until last Friday. For example, I have values below
07/01/11
08/07/11
07/15/11
07/22/11
07/29/11
05/08/11
12/08/11
19/08/11
26/08/11
02/09/11
09/09/11
......
I want to list all the values until last Friday. For example today it should show me data only until 08/26/11. Next week it should show me data only until 09/02/11 and so on. How to write an application to do?
Thanks for your time and your help.Hello
Assuming that the time data type is DATE, and this delay is not necessarily a Friday, you can do somehting like:
WHERE period <= TRUNC (SYSDATE + 3, 'IW') - 3
This is not your NLS settings.
If you run this on Friday, 2 September, then he will understand until September 2 itself.
The 'magic number' 3 reflects makes that your week begins 3 days before the ISO week (which begins Monday).
If you know this period is always a Friday, then it is simpler:
WHERE period <= SYSDATE
I hope that answers your question.
If not, post a small example data (CREATE TABLE and INSERT statements), some examples of performance dates (include at least a Friday) and results desired of each given rundate data of the sample.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using. -
Drivers for the following materials are not available for win7 on site.
Bluetooth controller
Hardware ID
PCI\VEN_1814 & DEV_3298 & SUBSYS_18EC103C & REV_00
PCI\VEN_1814 & DEV_3298 & SUBSYS_18EC103C
PCI\VEN_1814 & DEV_3298 & CC_0D1100
PCI\VEN_1814 & DEV_3298 & CC_0D11Network controller
Hardware ID
PCI\VEN_1814 & DEV_3290 & SUBSYS_18EC103C & REV_00
PCI\VEN_1814 & DEV_3290 & SUBSYS_18EC103C
PCI\VEN_1814 & DEV_3290 & CC_028000
PCI\VEN_1814 & DEV_3290 & CC_0280PCI simple communication controller
Hardware ID
PCI\VEN_8086 & DEV_9C3A & SUBSYS_2211103C & REV_04
PCI\VEN_8086 & DEV_9C3A & SUBSYS_2211103C
PCI\VEN_8086 & DEV_9C3A & CC_078000
PCI\VEN_8086 & DEV_9C3A & CC_0780Please help me to get it.
Thank you
Anshul
Hello:
See if they work...
Bluetooth controller:
http://h20566.www2.HP.com/hpsc/SWD/public/detail?swItemId=ob_130390_1
Network controller:
http://h20566.www2.HP.com/hpsc/SWD/public/detail?swItemId=ob_131223_1
PCI simple communication controller:
-
Single SQL query for the analysis of the date of customs declaration under the table of Stock codes
Dear all,
Please tell us a single SQL query for the below,
We have a Table of Stock as shown below,
STOCK_TABLE
ITEM_CODE
(item code)
BAT_NO
(lot no.)
TXN_CODE
(transaction code)
DOC_NO
(number)
BOE_DT
(date of the customs declaration)
I1
B1
I1
I2
I3
B70
I4
B80
I5
B90
T102
1234
JULY 2, 2015
I6
B100
We have to find the date of customs declaration (i.e. the date when the items have come under this particular table) for items that are not attached to any document (that is, who have TXN_CODE, DOC_NO and BOE_DT fields with a NULL value).
For each item in the table of actions, which is not attached to any document, the customs declaration date is calculated as follows.
- If (code section, lot number) combination is present under HISTORY_TABLE, the date of customs declaration will receive the UPDT_DT, the transaction code (TXN_CODE) is an IN or transactions (which can be analyzed from the TRANSACTIONS table).
- If (code section, lot number) combination is NOT currently at the HISTORY_TABLE (or) the transaction code respective to item - batch number combination code is an operation then customs declaration date will be the date of the document (DOC_DT) that we receive from one of the 3 tables IN_TABLE_HEAD that contains the element of that particular lot.
- If the case 1 and case 2 fails, our customs declaration date will be the last date of document (DOC_DT) that we receive from one of the 3 tables IN_TABLE_HEAD containing that particular item and the BAT_NO in expected results will be that corresponding to this document, as appropriate, to another NULL.
- If the case 1 or case 2 is successful, the value of the last field (in the output expected, shown further below) BATCH_YN will be 'Y', because it fits the lot. Otherwise it will be 'n'.
-
I built this different ways now, and I still get this same exact error. I spin as 'Admin' and I have so any available privilege.
There are no special characters in the password, I tried this file generation and he got away on my computer than this (v-soft bootable with interface).
Please help me get to the next step, I'm stuck here.
Everything seems fine until:
09/10/2013 18:00:25 [info] validation available disk space...09/10/2013 18:00:25 [info] prepares the operating system installation files.09/10/2013 18:00:25 [info] looking for /opt/vmware/www/ISV/ISO/CentOS-6.4-x86_64-bin-DVD1.iso09/10/2013 18:00:25 [info] Validating md5 checksum for /opt/vmware/www/ISV/ISO/CentOS-6.4-x86_64-bin-DVD1.iso (may take a few minutes)09/10/2013 18:01:15 [info] verification of repositories of request for the installation of the packages packet...09/10/2013 18:01:16 [info] creating package repositories...09/10/2013 18:01:16 [info] create the virtual machine model.09/10/2013 18:01:17 [info] VM carrying from the Studio to the host configuration. This may take a few minutes...09/10/2013 18:02:20 [warn] cannot download /opt/vmware/www/build/Tenacity.1/Tenacity.1_provstart.iso for the s-core9 data store.09/10/2013 18:02:20 [warn]%3 %7% 11% 15% 19% 23% 26% 30% 34% 38% 42 failure: (22, ' the requested URL returned error: 401')09/10/2013 18:02:20 [error] met a unrecoverable build error!I am able to use this model for Centos on my computer actually install and build a paralytic with centos on that - unfortunately I do a
hacks to make it work properly and I cannot get it to install other real applications (perhaps there is a new version for workstation 10?)
So I went to vsphere, and I KNOW my generation model is ok, at least to get the installed operating system.
What information can I give you or what can I try, thanks!
Is it really "sort of" loading ie 42% or which is a total failure?
OK, I have a build that WORKED, now I see what you mean about watching build/deploy the VM guest.
Here is the solution to my problem: our vcenter uses names with spaces, we also use the domain names for our connections. In addition, each admin password was 'special characters', that I've debugged meticulously by ALL of them and much more. Basically, it did not matter that I have "URL" code things, used new tools or edited different scripts to encode things one way or another.
What finally gave us successes was to go to a 'clean' Vcenter implementation that
(a) use/did not require a domain name (not / credentials)
(b) all had the "BACK original' legal names, IE no spaces, no special characters, etc..
(c) the passwords contained NO "special characters".
(because I changed this way, 'URL' encoding didn't work, tried it)
Moral of the story: building a new, simply configured Vcenter or get one and use it.
(Note: I even downloaded a new ovftool and tried every way that I could but it did not success)
-
I've owned a 755 p for almost a year now. For much of this time, my hotsyncs were jumping the Calendar/Contacts and calendar apps. These two work very well on the Palm Desktop and on the Treo itself. I checked the unit and the palm Desktop for corrupt files. There are not. When I was with Palm Desktop 4 (before 6 is available for XP), the lines were always listed as disabled. I could help and do a hotsync, but no data has been synchronized and would return to being disabled. If I tried to set it as enabled by default, the Hotsync application would break! So, I've lived with this absurd situation for 6 months now. Finally, I tried upgrading to Palm Desktop 6.2 and had no problem, but the problem persists. HotSync on the desktop PC simply ignores these lines entirely, even if it does not display error messages after a sync. The lines are listed as enabled.
I made a full backup and then uninstalled Palm Desktop 6.2 completely. Restarted and re-installed Palm Desktop 6.2 and tried to sync again. The problem persists.
My next step (and where I am now) would allow to debug and documented in the Hotsync application logging. Once I did, I discovered the specific problem, which apparently is entirely hidden from the end user. Here are the specific journal entries:
Led DateCond.dll: No association is found for the Creator ID "date." Conduit does not run.
Led DateCond.dll: No association is found for the Creator ID "SNLT". Conduit does not run.
Led AddrCond.dll: No association is found for the Creator ID 'addr '. Conduit does not run.
Led AddrCond.dll: No association is found for the Creator ID "PAdd". Conduit does not run.
I was not able to find something on the Internet about these errors. Nothing on the Palm site, nothing in these forums. I checked the database files are indeed on the handheld and have good creator ID. I don't understand how a complete re-installation of software still leaves it with a kind of missing association. But clearly there is something that lack prevents Hotsync to understand exactly what it is supposed to do here.
I can't just wipe my machine and start over. I have a lot of contacts and calendar on the device entries that are not on my PC and vice versa. Find and fix all those differences manually would be months of work with my limited free time. So if anyone has any suggestions on how to solve this problem, please let me know. And no, I'm not going to waste time calling support Palm. I gave up on the phone with Palm years ago support.
It's part of the problem. You might want to hard reset the device, and then rename the folder to BACKUP on the PC. (CProgram Files/Palm or Palmone / * Hotsync username * / Backup.) Change to the old files then synchronize with your existing username.
Message relates to: None
-
HI friends,
I need output like this.
Frequency (%) Cumulative
Frequency cumulative percentage
4468 0.91 0.91 4468
21092 4.31 25560 5.23
57818 11.82 83378 17.05
6274 1.28 89652 18.33
I use Oracle 9i.
My data of output like that and I need to write the query for 3 columns (for cent, the cumulative frequency and cumulative percentage)
1: the formula for the percentage column data is (frequency/amount of cumulative frequency) * 100
2: is the formula for the cumulative frequency column data (data of the cumulative frequency column of)
3: is the formula for the cumulative percentage column data (data for the cumulative percentage column of)
What should be the analytical function and how to write the query.
Thank you
LonyHi, Lony,
SUM is the function that adds several different line numbers:
SELECT frequency , percent , SUM (frequency) OVER (ORDER BY x) AS cumulative_frequency , SUM (percent) OVER (ORDER BY x) AS cumulative_percent FROM table_x ;
In your data, not frequency = 4468 on the first line, and not the line with frequency = 21092 come from then? If Yes, then you must have another column (or expression) that determines what are words like 'next', 'first' and 'after' means. I called x in the above query.
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
Explain, using specific examples, how you get these results from these data. Beespecially erase everything that makes a line come before or after the other.
Always tell what version of Oracle you are using.
See the FAQ forum {message identifier: = 9360002}It looks like you posted another copy of the same question: {message identifier: = 10271688} maybe it's not your fault; This site can be leafed through like that. No matter who's fault, mark the other thread as "Answered" immediately, so only look in one place to find answers, and other people won't waste their time, answering a question that is answered elsewhere.
-
How to write a query for the data exchange between two columns?
How to write a query for the data exchange between two columns?
I tried a request, does NOT work.
Thank you.update tmp t1 set t1.m1=t1.m2 and t1.m2=(select t2.m1 from tmp t2 where t2.student_id = t1.student_id)
Published by: user533361 on October 23, 2009 14:04Just plain and simple:
update tmp t1 set t1.m1=t1.m2, t1.m2=t1.m1 /
SY.
-
I can't get the automatic updates on my samsung jack sgh-i616.
"Connection to the update server is not available. "Check your data connection settings and make sure that the device date and time are correct.
RESULT CODE: 80072ee7
-It is a windows mobile 6.1
Thank you very much! = DAs a guide.
This error code translates ERROR_INTERNET_CANNOT_CONNECT.
You may encounter temporary connection related errors when you use Windows Update or Microsoft Update to install updates
http://support.Microsoft.com/kb/836941Harold Horne / TaurArian [MVP] 2005-2011. The information has been provided * being * with no guarantee or warranty.
-
I recently bought a new camera from Sony a7 - ii. the first time I tried to import raw images taken with it (with a. Suffix ARW) the program says "Preview not available for this file" and then "files are not recognized by the raw format support in Lightroom" I have the most updated version, I think as 5.7. What should I do to get these files imported as raw files?
Hi Bobsirkus,
The camera you have is compatible with the latest version of Lightroom, which is Lightroom 6/CC.
Please see the list of the camera supported by Lightroom: supported by Adobe Camera Raw devices
You can use the DNG Converter, converts images and then import them into DNG in Lightroom.
Kind regards
Tanuj
-
I just got my DVD for Lightroom 6 and it will not install and ReadMe directions do not resolve the issue or is not available. There is no .exe file I can find on the disk. What should I do?
Try it please link below:
I hope this helps.
Greetings
Megha Rawat
-
Hi, I need to download the acrobat PDF after registration and cc payment, I get the new which is not available for mac ist... How can I solve this problem... I use only the mac...
If you had bought subscription Acrobat Standard / stand-alone product , you need to cancel the subscription / order and re - register / re - order subscription Acrobat Pro DC / stand-alone product.
-
The data are stored in the DB for the Jdeveloper test, but not in the dev environment
The data are stored in the DB for the Jdeveloper test, but not in the dev environment
Hi all,
IM new with OFA and Im working with Jdeveloper, I create a form to store information using a VO and EO and add information to the current line using the attribute set of function, I noticed that when I lunch the update in the jdevelopher data is OK in the comic book, but when I install the development in the DEV environment the data stored using java code does not the table, only data that are related by the object as text fields and others.
This is the code that I use for SAP data, it works in jd, but not in the dev environment
{} public void saveData (String responsabilidadID)
int respId = Integer.parseInt (responsabilidadID);
OAViewObject vo = (OAViewObject) getQuiebresComercialesVO1 ();vo.getCurrentRow () .setAttribute ("ResponsabilidadId", respId);
getTransaction () .commit ();
}Any there who encounter this type of problem, something I can check?
Thank you all.
Just check if you bounced the server after you deploy the code. Objects Java would not reflect the changes, unless the instance is bounced.
HISTORY_TABLE
ITEM_CODE | BAT_NO |
TXN_CODE
DOC_NO
UPDT_DT
I1
B1
T1
1234
JANUARY 3, 2015
I1
B20
T20
4567
MARCH 3, 2015
I1
B30
T30
7890
FEBRUARY 5, 2015
I2
B40
T20
1234
JANUARY 1, 2015
TRANSACTION
TXN_CODE | TXN_TYPE |
T1 | IN |
T20 |
OFF
T30
ALL THE
T50
IN
T80
IN
T90
IN
T60
ALL THE
T70
ALL THE
T40
ALL THE
IN_TABLE_HEAD_1
H1_SYS_ID (primary key) | TXN_CODE | DOC_NO |
DOC_DATE
H1ID1
T1
1234
JANUARY 1, 2015
H1ID2
T70
1234
FEBRUARY 1, 2015
IN_TABLE_ITEM_1
I1_SYS_ID |
H1_SYS_ID
(foreign key referencing H1_SYS_ID in IN_TABLE_HEAD_1)
ITEM_CODE
I1ID1
H1ID1
I1
I1ID2
H1ID1
I100
I1ID3
H1ID2
I3
IN_TABLE_BATCH_1
B1_SYS_ID | TXN_CODE DOC_NO (now in IN_TABLE_HEAD_1) | BAT_NO |
B1ID1
T1
1234
B1 / can be empty
B1ID2
T70
1234
B70
IN_TABLE_HEAD_2
H2_SYS_ID (primary key) | TXN_CODE |
DOC_NO
DOC_DATE
H2ID1
T30
4567
FEBRUARY 3, 2015
H2ID2
T60
1234
JANUARY 3, 2015
IN_TABLE_ITEM_2
I2_SYS_ID | H2_SYS_ID (foreign key referencing H2_SYS_ID in IN_TABLE_HEAD_2) | ITEM_CODE |
I2ID1 | H2ID1 |
I1
I2ID2
H2ID1
I200
I2ID3
H2ID2
I2
IN_TABLE_BATCH_2
B2_SYS_ID |
I2_SYS_ID
(foreign key referencing I2_SYS_ID in IN_TABLE_ITEM_2)
BAT_NO
B2ID1
I2ID1
B30 / null
B2ID2
I2ID2
B90
B2ID2
I2ID3
B60
IN_TABLE_HEAD_3
H3_SYS_ID (primary key) | TXN_CODE | DOC_NO | DOC_DATE |
H3ID1 |
T50
1234
JANUARY 2, 2015
H3ID2
T80
1234
JANUARY 3, 2015
H3ID3
T90
1234
JANUARY 4, 2015
H3ID4
T40
1234
AUGUST 5, 2015
IN_TABLE_ITEM_3
I3_SYS_ID |
H3_SYS_ID
(foreign key referencing H3_SYS_ID in IN_TABLE_HEAD_3)
ITEM_CODE
BAT_NO
I3ID1
H31D1
I2
B50
I3ID2
H3ID2
I4
B40
I3ID3
H3ID3
I4
I3ID4
H3ID4
I6
There is no IN_TABLE_BATCH_3
Please find below the expected results.
OUTPUT
ITEM_CODE | BAT_NO | TXN_CODE | DOC_NO |
BOE_DT
BATCH_YN
I1
B1
T1
1234
JANUARY 3, 2015
THERE
I1
B30
T30
7890
FEBRUARY 5, 2015
N
I2
B60
T60
1234
JANUARY 3, 2015
N
I3
B70
T70
1234
FEBRUARY 1, 2015
THERE
I4
T90
1234
JANUARY 4, 2015
N
I6
T40
1234
AUGUST 5, 2015
N
Controls database to create the tables above and insert the records.
CREATE TABLE stock_table()item_code VARCHAR2()80),bat_no VARCHAR2()80),txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), boe_dt DATE );
INSERT EN stock_table
VALUES ('I1', 'B1', '', '', '');
INSERT EN stock_table
VALUES ('I1', '', '', '', '');
INSERT IN stock_table
VALUES ('I2', '', '', '', '');
INSERT EN stock_table
VALUES ('I3', 'B70', '', '', '');
INSERT EN stock_table
VALUES ('I4', 'B80', '', '', '');
INSERT EN stock_table
VALUES ('I5', 'B90', 'T102', '1234', '02-JUL-2015');
INSERT EN stock_table
VALUES ('I6', 'B100', '', '', '');
SELECT *
FROM stock_table
CREATE TABLE history_table()item_code VARCHAR2()80),bat_no VARCHAR2()80),txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), updt_dt DATE );
INSERT IN history_table
VALUES ('I1', 'B1', 'T1', '1234', '03-JAN-2015');
INSERT IN history_table
VALUES ('I1', 'B20', 'T20', '4567', '03-MAR-2015');
INSERT IN history_table
VALUES ('I1', 'B30', 'T30', '7890', '05-FEB-2015');
INSERT IN history_table
VALUES ('I2', 'B40', 'T20', '1234', '01-JAN-2015');
SELECT *
FROM history_table
CREATE TABLE transaction1()txn_code VARCHAR()80),txn_type VARCHAR()80));
INSERT INTO transaction1
VALUES ('T1', 'IN');
INSERT INTO transaction1
VALUES ('T20', 'OUT');
INSERT INTO transaction1
VALUES ('T30', 'ALL');
INSERT INTO transaction1
VALUES ('T40', 'ALL');
INSERT INTO transaction1
VALUES ('T50', 'IN');
INSERT INTO transaction1
VALUES ('T60', 'ALL');
INSERT INTO transaction1
VALUES ('T70', 'ALL');
INSERT INTO transaction1
VALUES ('T80', 'IN');
INSERT INTO transaction1
VALUES ('T90', 'IN');
SELECT *
FROM transaction1
CREATE TABLE in_table_head_1()h1_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), doc_dt DATE );
CREATE TABLE in_table_head_2()h2_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), doc_dt DATE );
CREATE TABLE in_table_head_3()h3_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),
doc_no VARCHAR2 (80), doc_dt DATE );
INSERT IN in_table_head_1
VALUES ('H1ID1', 'T1', '1234', '01-JAN-2015');
INSERT IN in_table_head_1
VALUES ('H1ID2', 'T70', '1234', '01-FEB-2015');
INSERT IN in_table_head_2
VALUES ('H2ID1', 'T30', '4567', '03-FEB-2015');
INSERT IN in_table_head_2
VALUES ('H2ID2', 'T60', '1234', '03-JAN-2015');
INSERT IN in_table_head_3
VALUES ('H3ID1', 'T50', '1234', '02-JAN-2015');
INSERT IN in_table_head_3
VALUES ('H3ID2', 'T80', '1234', '03-JAN-2015');
INSERT IN in_table_head_3
VALUES ('H3ID3', 'T90', '1234', '05-JAN-2015');
INSERT IN in_table_head_3
VALUES ('H3ID4', 'T40', '1234', '05-AUG-2015');
CREATE TABLE in_table_item_1()i1_sys_id VARCHAR2()80) PRIMARY KEY,
h1_sys_id VARCHAR2 (80) REFERENCES in_table_head_1()h1_sys_id),item_code VARCHAR2()80));
CREATE TABLE in_table_item_2()i2_sys_id VARCHAR2()80) PRIMARY KEY,
h2_sys_id VARCHAR2 (80) REFERENCES in_table_head_2()h2_sys_id),item_code VARCHAR2()80));
CREATE TABLE in_table_item_3(i3_sys_id VARCHAR2(80) PRIMARY KEY,
h3_sys_id VARCHAR2 (80) REFERENCES in_table_head_3()h3_sys_id),item_code VARCHAR2()80),
bat_no VARCHAR2 (80));
INSERT IN in_table_item_1
VALUES ('I1ID1', 'H1ID1', 'I1');
INSERT IN in_table_item_1
VALUES ('I1ID2', 'H1ID1', 'I100');
INSERT IN in_table_item_1
VALUES ('I1ID3', 'H1ID2', 'I3');
INSERT IN in_table_item_2
VALUES ('I2ID1', 'H2ID1', 'I1');
INSERT IN in_table_item_2
VALUES ('I2ID2', 'H2ID1', 'I200');
INSERT IN in_table_item_2
VALUES ('I2ID3', 'H2ID2', 'I2');
INSERT IN in_table_item_3
VALUES ('I3ID1', 'H3ID1', 'I2','B50');
INSERT IN in_table_item_3
VALUES ('I3ID2', 'H3ID2', 'I4','B40');
INSERT IN in_table_item_3
VALUES ('I3ID3', 'H3ID3', 'I4','');
INSERT IN in_table_item_3
VALUES ('I3ID4', 'H3ID4', 'I6','');
SELECT *
FROM in_table_item_1
SELECT *
FROM in_table_item_2
SELECT *
FROM in_table_item_3
CREATE TABLE in_table_batch_1()b1_sys_id VARCHAR2()80) PRIMARY KEY,
txn_code VARCHAR2 (80), doc_no VARCHAR2 (80), bat_no VARCHAR2 (80));
CREATE TABLE in_table_batch_2()b2_sys_id VARCHAR2()80) PRIMARY KEY,
i2_sys_id VARCHAR2 (80) REFERENCES in_table_item_2()i2_sys_id),bat_no VARCHAR2()80));
INSERT IN in_table_batch_1
VALUES ('B1ID1', 'T1', '1234', 'B1');
INSERT IN in_table_batch_1
VALUES ('B1ID2', 'T70', '1234', 'B70');
INSERT IN in_table_batch_2
VALUES ('B2ID1', 'I2ID1', 'B30');
INSERT IN in_table_batch_2
VALUES ('B2ID2', 'I2ID2', 'B90');
INSERT IN in_table_batch_2
VALUES ('B2ID3', 'I2ID3', 'B60');
Please advise a solution for the same.
Thank you and best regards,
Séverine Suresh
very forced (question subfactoring used to allow easy testing/verification - could work with these test data only)
with
case_1 as
(select s.item_code,
s.bat_no,
h.txn_code,
h.doc_no,
h.updt_dt boe_dt,
cases where s.bat_no = h.bat_no then 'Y' else ' n end batch_yn.
cases where h.txn_code is not null
and h.doc_no is not null
and h.updt_dt is not null
then 'case 1' '.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, boe_dt
of w_stock_table
where bat_no is null
or txn_code is null
or doc_no is null
or boe_dt is null
) s
left outer join
w_history_table h
On s.item_code = h.item_code
and s.bat_no = h.bat_no
and exists (select null
of w_transaction1
where txn_code = nvl (s.txn_code, h.txn_code)
and txn_type in ('IN', 'ALL')
)
),
case_2 as
(select s.item_code,
NVL (s.bat_no, h.bat_no) bat_no.
NVL (s.txn_code, h.txn_code) txn_code.
NVL (s.doc_no, h.doc_no) doc_no.
NVL (s.boe_dt, h.updt_dt) updt_dt.
cases where s.bat_no = h.bat_no then 'Y' else ' n end batch_yn.
cases where h.txn_code is not null
and h.doc_no is not null
and h.updt_dt is not null
then 'case 2'.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, boe_dt
of case_1
where refers_to is null
) s
left outer join
w_history_table h
On s.item_code = h.item_code
and exists (select null
of w_transaction1
where txn_code = nvl (s.txn_code, h.txn_code)
and txn_type in ('IN', 'ALL')
)
and not exists (select null
of case_1
where item_code = h.item_code
and bat_no = h.bat_no
and txn_code = h.txn_code
and doc_no = h.doc_no
and updt_dt = h.updt_dt
)
),
case_31 as
(select s1.item_code,
NVL (S1.bat_no, W1.bat_no) bat_no.
NVL (S1.txn_code, W1.txn_code) txn_code.
NVL (S1.doc_no, W1.doc_no) doc_no.
NVL (S1.updt_dt, W1.doc_dt) updt_dt.
cases where s1.bat_no = w1.bat_no then 'Y' else ' n end batch_yn.
cases where w1.txn_code is not null
and w1.doc_no is not null
and w1.doc_dt is not null
then "case 31'.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to
of case_2
where refers_to is null
) s1
left outer join
(select i1.item_code, h1.txn_code, h1.doc_no, h1.doc_dt, b1.bat_no
of w_in_table_item_1 i1
inner join
w_in_table_head_1 h1
On i1.h1_sys_id = h1.h1_sys_id
inner join
w_in_table_batch_1 b1
On h1.txn_code = b1.txn_code
and h1.doc_no = b1.doc_no
) w1
On s1.item_code = w1.item_code
),
case_32 as
(select s2.item_code,
NVL (S2.bat_no, W2.bat_no) bat_no.
NVL (S2.txn_code, W2.txn_code) txn_code.
NVL (S2.doc_no, W2.doc_no) doc_no.
NVL (S2.updt_dt, W2.doc_dt) updt_dt.
cases where s2.bat_no = w2.bat_no then 'Y' else ' n end batch_yn.
cases where w2.txn_code is not null
and w2.doc_no is not null
and w2.doc_dt is not null
then "case 32'.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to
of case_2
where refers_to is null
) s2
left outer join
(select i2.item_code, h2.txn_code, h2.doc_no, h2.doc_dt, b2.bat_no
of w_in_table_item_2 i2
inner join
w_in_table_head_2 h2
On i2.h2_sys_id = h2.h2_sys_id
inner join
w_in_table_batch_2 b2
On i2.i2_sys_id = b2.i2_sys_id
) w2
On s2.item_code = w2.item_code
),
case_33 as
(select s3.item_code,
w3.bat_no,
NVL (S3.txn_code, w3.txn_code) txn_code.
NVL (S3.doc_no, w3.doc_no) doc_no.
NVL (S3.updt_dt, w3.doc_dt) updt_dt.
cases where s3.bat_no = w3.bat_no then 'Y' else ' n end batch_yn.
cases where w3.txn_code is not null
and w3.doc_no is not null
and w3.doc_dt is not null
then "case 33'.
end refers_to
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to
of case_2
where refers_to is null
) s3
left outer join
(select i3.item_code, h3.txn_code, h3.doc_no, h3.doc_dt, i3.bat_no
of w_in_table_item_3 i3
inner join
w_in_table_head_3 h3
On i3.h3_sys_id = h3.h3_sys_id
) w3
On s3.item_code = w3.item_code
)
Select item_code, bat_no, txn_code, doc_no, boe_dt, batch_yn
of case_1
where refers_to is not null
Union of all the
Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
of case_2
where refers_to is not null
Union of all the
Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn,
ROW_NUMBER() over (partition by item_code of updt_dt desc order) rn
from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
of case_31
where refers_to is not null
Union of all the
Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
of case_32
where refers_to is not null
Union of all the
Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn
of case_33
where refers_to is not null
)
)
where rn = 1
ITEM_CODE | BAT_NO | TXN_CODE | DOC_NO | BOE_DT | BATCH_YN |
---|---|---|---|---|---|
I1 | B1 | T1 | 1234 | JANUARY 3, 2015 | THERE |
I1 | B30 | T30 | 7890 | FEBRUARY 5, 2015 | N |
I2 | B60 | T60 | 1234 | JANUARY 3, 2015 | N |
I3 | B70 | T70 | 1234 | FEBRUARY 1, 2015 | THERE |
I4 | - | T90 | 1234 | JANUARY 5, 2015 | N |
I6 | - | T40 | 1234 | AUGUST 5, 2015 | N |
Concerning
Etbin
Maybe you are looking for
-
Cannot reconnect the external hard drive
Cannot reconnect the external hard drive after moving the computer. I have a WD external hard drive and after moving computer cant use. It is used to mount drive f and now in the g drive. He keeps asking me to format the disk before it can be used, b
-
Hi, I think bidirection means "entry and exit", so I plugged the output pin of the ADC at the entrance of MC74AC245DW. Then use 'rules electical check', there are 8 errors. ERC [Circuit1]Error: Connection "two-way out." [U3 pin 9, Circuit1] to [A1
-
800705AA error trying to install patches for Microsoft Vista
Hi I have a Vista computer that won't let me install the Microsoft updates XP1 SP1WUpdateetc. Whenever I get just the 800705aa error message Some internet research suggest it is perhaps a matter of resources, but the machine is moderate with lots of
-
Is the microsoft tool or software cleaning for all xp, vista & windows 7
All the cleaning tools for all the xp, vista & windows 7 microsoft is similar to ccleaner
-
What is the best way to clean all simulators? Currently I have a RIM BB JDE installed 4.2.0.98 that works with the default 8100 Simulator. I am only able to reset [clean] 8100 Simulator using clean.bat. I installed other simulators, BB 8820 and BB 85