SQL question for a beginner...
I have the following structure:NUMBER OF PROCESSING_ITEM_ID
NUMBER OF PROJECT_ITEM_FK
START_TIME DATE
END_TIME DATE
NUMBER OF WORKSTATION_FK
examples of data
81,23,10-27-2010 08:00, 27/10/2010 10:00, 3
42,1,10-27-2010 08:00, 27/10/2010 11:00, 1
22,23,10-27-2010 13:00, 27/10/2010 17:00, 2
1,23,10-27-2010 15:00, 27/10/2010 16:00, 1
23,23,10-27-2010 17:00, 27/10/2010 20:00, 2
I'm trying to divide the data into lines of an hour. If this line we would be divided into:
81,23,10-27-2010 08:00, 27/10/2010 09:00, 3
81,23,10-27-2010 09:00, 27/10/2010 10:00, 3
third row would be divided into:
22,23,10-27-2010 13:00, 27/10/2010 14:00, 2
22,23,10-27-2010 14:00, 27/10/2010 15:00, 2
22,23,10-27-2010 15:00, 27/10/2010 16:00, 2
22,23,10-27-2010 16:00, 27/10/2010 17:00, 2
The statement that is made should display the data in this way...
John Brewer
City of Seattle
Question delicate John, you should ask this in the SQL forums
This is the query
with temp AS
(
SELECT 81 PROCESSING_ITEM_ID,23 PROJECT_ITEM_FK,TO_DATE('10-27-2010 08:00','MM-DD-YYYY HH24:MI') start_date,TO_DATE('10-27-2010 10:00','MM-DD-YYYY HH24:MI') end_date,3 WORKSTATION_FK from dual
UNION ALL
SELECT 22 PROCESSING_ITEM_ID,23 PROJECT_ITEM_FK,TO_DATE('10-27-2010 13:00','MM-DD-YYYY HH24:MI') start_date,TO_DATE('10-27-2010 17:00','MM-DD-YYYY HH24:MI') end_date,2 WORKSTATION_FK from dual
)
,time_span AS
(
SELECT MAX( TO_NUMBER(TO_CHAR(end_date,'HH24')) - TO_NUMBER(TO_CHAR(start_date,'HH24')) ) TIME_SPAN
FROM temp
)
,time_period_rows AS
(
SELECT level-1 PERIOD FROM time_span connect by level <= TIME_SPAN
)
SELECT T.PROCESSING_ITEM_ID,T.PROJECT_ITEM_FK,TO_CHAR(T.start_date+TR.PERIOD/24,'MM-DD-YYYY HH24:MI') start_time,TO_CHAR(T.start_date+(TR.PERIOD+1)/24,'MM-DD-YYYY HH24:MI') end_time ,T.WORKSTATION_FK
FROM temp T
,time_period_rows TR
WHERE PERIOD <= TO_NUMBER(TO_CHAR(end_date,'HH24')) - TO_NUMBER(TO_CHAR(start_date,'HH24'))
ORDER BY T.PROCESSING_ITEM_ID,TR.PERIOD
Output
PROCESSING_ITEM_ID PROJECT_ITEM_FK START_TIME END_TIME WORKSTATION_FK
22 23 10-27-2010 13:00 10-27-2010 14:00 2
22 23 10-27-2010 14:00 10-27-2010 15:00 2
22 23 10-27-2010 15:00 10-27-2010 16:00 2
22 23 10-27-2010 16:00 10-27-2010 17:00 2
81 23 10-27-2010 08:00 10-27-2010 09:00 3
81 23 10-27-2010 09:00 10-27-2010 10:00 3
81 23 10-27-2010 10:00 10-27-2010 11:00 3
I used a view inline as data source ( temp ), you can change this to your table, name (then remove the display online)
Tags: Database
Similar Questions
-
Fusion/Windows 7 tips &; questions for a beginner
Hey guys (and girls) I've been a linux user especially lately so I more or less missed the boat on windows 7 but I'm looking to load on my MBP, but I have a few newbie questions if can help people. I tried to do a search, but I think that my terminology or the lack of good conditions got in my way.
Some background information, I use a unibody MBP with 4 GB of ram 5.1 which has Snow Leopard and VMware fusion 3.01.
I am interested in what would work well with the merger of two ways, bootcamp vs install a vmdk and 64-bit vs 32-bit...
First of all is it an advantage to running vmware fusion with bootcamp, IE merge use the bootcamp partition? What I see better performance if I instead of use the bootcamp created a virtual machine (vmdk) within the merger?
Second question is about 32-bit vs 64-bit. I'm under 4gig of RAM which I will devote only 2gig in vmware. Is it interesting (stability, or performance) to the use of 64-bit within the fusion flavor (vm installed not bootcamp) or I'll be better with 32-bit installation?
If I'm melting point using the bootcamp partition, is third question - interesting to settle current with the 64-bit or 32-bit. It's merger would provide more performance with the bootcamp windows 7 32 bit, and vice versa (or it does not matter)
Fourth question, seems, the fusion installs things when you use the bootcamp partition and I guess I'll need to install the tools as well. That will cause problems, or headaches when I boot physically in training camp, that is, drivers of devices for non-existent devices. What video, nvidia 9600 m in bootcamp vs virtual gpu fusion provides. I can't wait to see problems when I turned off and restart under bootcamp.
Last question, I will visit the hell of activation if the bootcamp partition uses two cores, but I just dedicate a molten core when you point the merger to use the bootcamp partition. I don't want to always have to re - activate win7 because when I boot in bootcamp, he sees two hearts but merger only when.
Thanks in advance
Mike
take a deep breath... OK... =)
Firstly there is an advantage to running vmware fusion with bootcamp
You get better performance out of hard in this instance. With the help of a physical disk is not the OS X volume would be better than BootCamp, but of course only applicable on a Mac Pro. Rationale: with multiple partitions, the needle on the hard disk has a long way to the second partition, back and forth all the time between Windows and Mac does travel. A hard, as a general rule, would include a contiguous space due to the Mac file system optimizing the layer of block on the fly.
The advantage of using BootCamp is if you need to take advantage of the full potential of the Mac hardware in a dedicated Windows environment. Such use might be to, say, play games of high quality, latest (Call of Duty, anyone?), at higher resolutions / great detail. Ditto for just about any application for Windows which needs a beefy video system (OpenGL rendering, CAD, stuff like that)
Is it interesting (stability, or performance) to the use of 64-bit within the fusion flavor (vm installed not bootcamp) or I'll be better with 32-bit installation?
I would say that no, there is no significant advantage to the use of 64 vs 32 bit in a virtual machine. Stick to 32, it is more compatible with the software and any equipment that you choose to give to Windows (driver for 64-bit stuff support is usually OK, but there is no compelling reason to do it in a virtual machine)
If I'm melting point using the bootcamp partition, is third question - interesting to settle current with the 64-bit or 32-bit.
Windows 7 is not supported by BootCamp by Apple, so probably 64 bit will not be 100% working drivers.
Fourth question, seems, the fusion installs things when you use the bootcamp partition and I guess I'll need to install the tools as well.
We install tools (drivers and additional software), as well as some tips for handling activation. So we keep some of the files that Windows uses to verify that it has been activated, but due to the change in material Windows must activate two times. Record us each activation, detect when Windows runs in our VM and present key information and activating appropriate to the operating system (to keep him from having to activate every time you pass ="
What video, nvidia 9600 m in bootcamp vs virtual gpu fusion provides. I can't wait to see problems when I turned off and restart under bootcamp.
I did not talk about all issues related to the video does not when it is started normally. Windows detects that hardware is present at startup, check if it uses drivers and goes from there.
Last question, I will visit the hell of activation if the bootcamp partition uses two cores, but I just dedicate a molten core when you point the merger to use the bootcamp partition
N ° again, we keep the profile "enabled" and save it. When the BONE is introduced in the merger, we use our activation profile. When you started in native mode, it uses that have never appeared by activating in Bootcamp.
The direct answer to 'can I use bootcamp or hard' would be: depends on what you want to do with the virtual machine. If it's general things, you're good... If you're a gamer or CAD designer, BootCamp is a good option. =)
-
Hello world
I spent about half a day looking for what I want. I read the guide to Illustrator scripts and browsed forums but I can't find an answer so here's my question:
I have an Illustrator file.
I have 3 layers in this file called "L", "M" and "S" (for size).
In each layer, there are two elements of text with something written inside. They are always named 'Name' and 'number '. I created everything using my mouse and keyboard, no script.
It looks like:
L (layer)
Name (text)
Number (text)
M (layer)
Name (text)
Number (text)
S (layer)
Name (text)
Number (text)
I want to choose a specific name in the M layer, for example. I can't find a way to do...
myDoc = app.activeDocument var
myLayer = myDoc.layers var [1] / * myLayer is "M" * /.I read that it is possible to access the textframe wanted to help: myDoc.textFrames [2] / * 2 refers to the third text element within the framework of related texts document. */
My problem is that I can have a big file with tons of other executives of related texts, so I would get called a 'name' in the layer of "M" without knowing his rank in the frames of related texts document.
I tried var myText = myDoc.myLayer.textFrame but obviously myLayer didn't linked text frames, it only works with documents, or I missed something.
I hope that you guys understand my problem.
Thank you for your help.
Hi totom, welcome to the forum
Layers have linked text frames, you were very close, here is the syntax to do what you want
var idoc = app.activeDocument; var ilayer = idoc.layers["M"]; var iframe = ilayer.textFrames["Name"]; iframe.selected = true;
-
Another easy question for a beginner
Example: Pig picks up Apple with pig.addChild (apple);
If, say, a bird wants the Apple but the pig there:
If (bird.hitTestObject (apple)
{
bird.addChild (apple);
Apple.x = 0;
Apple.y = 0;
}
and the pork and the apple touch the bird, Apple remains with the pig.
If an object is a child of another object like the pig, it's (the Apple in this case) dependent on only this object (the pig)?
Thanks for any input
Shiim
You are welcome.
p.s. Please mark this thread as answered.
-
ODBC SQL Server for Solaris 64-bit drivers
Does anyone know if there is a driver available for ODBC SQL Server for Solaris 64 bit server?
Thank you
CB
[edit: moved to SQL Server questions]
Ask the question in the SQL Server forums:
http://social.msdn.Microsoft.com/forums/SQLServer/en-us/home?category=SQLServer -
Hardware requirements for MS SQL Server for about 100 concurrent users
Can someone suggest the hardware configuration required for MS SQL Server for about 100 concurrent users?
Microsoft page suggests 2 GHz CPU and 4 GB of RAM, but it does not mention the number of users. Wonder how many users affects the performance of MS SQL.Your question of Windows 7 is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for Windows Server on MSDN. Please post your question in the MSDN Windows Server forum.
http://social.msdn.Microsoft.com/forums/en-us/category/SQLServer/
-
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'.
-
Oracle cert exams are equal weight to each of the questions - for example 1z0-117?
Oracle cert exams are equal weight to each of the questions - for example 1z0-117?
For example, 1z0-117 Oracle 11 g r2 SQL Tuning has 75 questions.
Some of these questions you will have to look a long explain plan
and determine what is happening.
Other issues could be just take 2 of the 4.
Is equal weight each question.
Roger
Is equal weight each question.
Yes. And each issue is 100% right or 100% false. There is no middle ground with multiple answer questions.
-
I am a beginner in Adobe software and I'm working on an intro for my website using After Effects. I'd appreciate it if someone could help me. My computer is a Mac and I use Teamviewer to cooperate in partnerships of long distances. My Skype is cspencer3358. Add me and leave a message for more details.
It is a public forum and all help freely given on this forum, by me at least, is intended for everyone. If you have a specific question for specific effect you want to achieve, we can formulate an answer let help me you help, you and others on the forum. If you want private lessons, so I have to pay for it.
-
Hi expert,
When I ran after SQL, error message reads "table or view does not exist" pointing to the table "dba_tab_cols" and "dba_all_tables". There is no other question for this statement, because if I changed table "user_tab_cols" and "user_all_tables", it works well.
declare
v_old_table DBA_tab_columns.table_name%type;
v_where Varchar2 (4000);
Boolean v_first_col: = true;
type rc is ref cursor;
c rc;
v_rowid varchar2 (20);
Val varchar2 (50): = "Test note";
Start
for r in)
Select
t.*
Of
dba_tab_cols t, dba_all_tables a
where t.table_name = a.table_name
and t.data_type like '% CHAR % '.
and a.owner = 'QA'
order by t.table_name loop)
If v_old_table is null then
v_old_table: = r.table_name;
end if;
If v_old_table <>r.table_name then
v_first_col: = true;
-dbms_output.put_line ('search' | v_old_table);
Open c for ' select rowid from ' ' |. ' v_old_table | '" ' || v_where;
extract the c in v_rowid;
loop
When the output c % notfound;
dbms_output.put_line (' rowid: ' | v_rowid |) "in" | v_old_table);
extract the c in v_rowid;
end loop;
v_old_table: = r.table_name;
end if;
If v_first_col then
v_where: = 'where ' | r.column_name | "as" %' | Val | '%''';
v_first_col: = false;
on the other
v_where: = v_where | "or" | r.column_name | "as" %' | Val | '%''';
end if;
end loop;
end;
But if I choose these DBA tables in the toad sql Editor, it works well, I am currently using my own credentials, not the administrator credentials. why he get different effects running in these two ways?
Thank you very much>
Hello
When I ran after SQL, error message reads "table or view does not exist" pointing to
Table 'dba_tab_cols' and 'dba_all_tables '. There is no other question for this statement, becauseIf I changed table "user_tab_cols" and "user_all_tables", it works well.
But if I choose these DBA tables in the toad sql Editor, it works well, I am currently using my own
credentials, not the administrator credentials. why he get different effects running in these two ways?You answered your own question - you know that you have the administrator privileges when you
Open a session under your own credentials - but your id user obviously does TOAD.You use SQL * for the query that fails?
BTW, you do not give us your version of Oracle - you must always tell us what it is
Please read the forum FAQ and also the thread "sticky" by BluShadow at the top of the list of positions
on the forum homepage. These forums are an excellent resource - you will get the best out of them if
you follow the instructions.HTH,
Paul...
Published by: Paulie July 24, 2012 16:40
-
Hi all I have a basic sql question
Watch below two querries
I think as operator will not compare with all the values, but not the outcome it will compare with all values... When comparing with the value null, the result is automatically null1. select 1 from dual where 1 in (select 1 from dual union all select null from dual) It gives output as 1 but below one 2. select 1 from dual where 1 not in (select 2 from dual union all select null from dual) It gives output as no data found
I'm wrong
Please help me on this
and why performance wise in operator is more better than no of?
Thanks to all in advanceThanks for posting your explain plan command
Execution Plan ---------------------------------------------------------- Plan hash value: 3249215828 ----------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 2 | 6 | 4 (0)| 00:00:01 | | 1 | NESTED LOOPS | | 2 | 6 | 4 (0)| 00:00:01 | | 2 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 | | 3 | VIEW | VW_NSO_1 | 2 | 6 | 2 (0)| 00:00:01 | | 4 | SORT UNIQUE | | 2 | | 2 (0)| 00:00:01 | | 5 | UNION-ALL | | | | | | | 6 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 | |* 7 | FILTER | | | | | | | 8 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 | ----------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 7 - filter(NULL IS NOT NULL) 02:12:54 SQL> select 1 from dual where 1 not in (select 2 from dual union all select null from dual); Elapsed: 00:00:00.01 Execution Plan ---------------------------------------------------------- Plan hash value: 3291682568 ----------------------------------------------------------------- | Id | Operation | Name | Rows | Cost (%CPU)| Time | ----------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 4 (0)| 00:00:01 | |* 1 | FILTER | | | | | | 2 | FAST DUAL | | 1 | 2 (0)| 00:00:01 | | 3 | UNION-ALL | | | | | |* 4 | FILTER | | | | | | 5 | FAST DUAL | | 1 | 2 (0)| 00:00:01 | | 6 | FAST DUAL | | 1 | 2 (0)| 00:00:01 | -----------------------------------------------------------------
-
I need issue of SQL/PLSQL for practice
Hi all
I need to question of SQL/PLSQL for practice; could everything on send me the URL.
I need only the PDF file.
Thank you
GregoryHere is the link for the link of PL/SQL oracle
http://www.Oracle.com/pls/db111/portal.portal_db?selected=5&frame=
IN the section of SQL and PL/SQL language, there is the language Pl/SQL.. PDF reference .you can download... its preety good to start.
-
Question for the geniuses of pictures only.
Question for the geniuses of pictures only.
You see, I started with iPhoto and later began to use Aperture. With iPhoto and Aperture, you can have ALL the metadata below the thumbnails, (nice). Well, I put all my images descriptions in the keywords section because it didn't really matter, because these programs could show them as thumbnails.
Now, I use this wonderful program of Photos and I found out that it will ONLY show the title of"the image in the thumbnails. I've got on 30 000 images with keywords but no title. I want to move / copy the text in the keywords section in the section of the title. I'm not a computer scientist, I guess that my skills are in average. But I can follow directions.
Suggestions appreciated.
Member of ASC compiled some useful on Photos AppleScripts. Maybe one of them will be sufficiently close to your needs.
-
How to get assistance from mozilla to answer questions for windows when I use a macintosh computer
How to get assistance from mozilla to answer questions for windows when I use a macintosh computer?
Look on the right side of the knowlegde base articles, where it is said ' help to ". Here, you can change the operating system and the version of firefox. The content of the article will adjust.
If you ask a question on the help forum, you can simply say this in your question. -
Question for Microsoft Support;
I have a LARGE amount of files music .m4a in a storage drive stand alone that I downloaded from an old Apple computer have more possession of. I can't understand how to enter these data into my old Emachines computer Windows Vista run the Media Player program. I tried to copy a few files m4a manually in the file Media Player Music folder, but they do not play. I'm not really all that computer savvy and know only the basics, I need to use my computer really. Can you give me some step by step instructions how to get these converted files or whatever it is I need to do to get them to play and to integrate properly into my library if it is possible? If this isn't the case, I'll have to go out and buy a new Apple computer for my 60 GB music collection. In the past, that I've never had no real problem shooting files to leave this computer based Vista and convert these files to my old computers Apple Itunes Player. So what's the problem with your system of guys that done anyway this such a pain in the butt? I would really like to understand what exactly is happening with this issue? It's very frustrating for me. I'm a finish Carpenter not a computer programmer. Such things should not be so difficult for someone like me to understand. All I intend to buy a really nice computer, probably in the summer and was considering a Microsoft based computer. But if this kind of problem will be spread with Microsoft products, so maybe I should reconsider. help you can offer to alleviate this problem will be greatly appreciated.
Thank you
Signed;
Tim M. from Detroit.According to research on the Internet, Windows Media Player, atleast this is version 11 (included in Windows Vista and available for Windows XP SP2 +) cannot play Apple loseless type .m4a audio files without having to install any codecs.
If you want to use Windows Media Player, you can follow the instructions mentioned here to install the necessary codecs and plugins.
(In the related instructions above, in the first step talks about codecs - your .m4a files are files Apple loseless then follow the party referred to in the first stage about Apple loseless .m4a)
Personally, I prefer using alternatives to Windows Media Player rather than installing codec packs.
If you don't want to install codecs, download no matter what media player from "programs that open. M4A files"- Windows category list on this page.
If you use a spare player - VLC Media Player is my choice.
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
-
Look at the different time to local time
I went to the settings and changed to local time, an hour before. Now, I can't return to standard time time. I tried to cancel it and return it, but he wants to let do me.
-
How would you apply different calibrations on different channels
I'm looking to apply the calibration data to multiple channels. The calibrations could be made at different times for different channels and could be using different adjustments. I think I have a solution to just apply the calibration on a channel in
-
HP Envy m6-1125dx: HP Envy m6-1125dx Windows 7 Pro 64
I really want to use Windows 7 64 with this laptop. I already bought a copy of Windows 7 Pro 64 bit retail and went through the installation on the laptop but I am not able to find drivers for it. Not even the network driver. Does anyone have pointer
-
WiFi feature is disabled in my laptop Lenovo 50-80 32-bit windows 7
I'm using Lenovo laptop 50-80 with OS 32-bit windows 7. my wifi is not working if I diagnose its wireless capability display option is disabled I double on pilot because his windows preinstalled 8.1 64 bit OS then I changed to windows 7 32 bit. Lenov
-
Try to install the printer HP laserjet 1012
I just got a new computer with windows 7. I tried to install my printer HP laserjet printer HP laserjet 1012. I have the installation disc, but it does not work and the HP site does not list the drivers for this printer. I'm out of luck, or there