Best way to join 2 columns from table A to same column in Table B?
Hi,
This is a simplified example of the query I'm trying to write.
I have two tables - PIPELINE (which includes columns CREDIT_RECEIVER and CREATOR) and EMPLOYEES (which includes columns EMAIL and LOB).
I want to write a query which joins PIPELINE.CREDIT_RECEIVER with EMPLOYEES.EMAIL to return LOB as "CREDIT_RECEIVER_LOB".
I also want this query to join PIPELINE.CREATOR with EMPLOYEES.EMAIL to return LOB as "CREATOR_LOB".
Currently, I am doing a left outer join on EMPLOYEES.EMAIL = PIPELINE.CREDIT_RECEIVER to get "CREDIT_RECEIVER_LOB", and calling a function GET_LOB(PIPELINE.CREATOR) (defined below) to get "CREATOR_LOB".
Query:
Select PIPELINE.ID as ID,
PIPELINE.CREDIT_RECEIVER as CREDIT_RECEIVER,
PIPELINE.CREATOR as CREATOR,
EMPLOYEES.LOB as CREDIT_RECEIVER_LOB,
GET_LOB(PIPELINE.CREATOR) as CREATOR_LOB
FROM PIPELINE
LEFT OUTER JOIN EMPLOYEES ON PIPELINE.CREDIT_RECEIVER=EMPLOYEES.EMAIL
Is there a more efficient way to write this query? This query is so slow that it usually times out on me.
Thanks,
Forrest
GET_LOB definition
create or replace function "GET_LOB"
(vemail in VARCHAR2)
return VARCHAR2
is
begin
DECLARE vLOB VARCHAR2(30);
BEGIN
SELECT LOB INTO vLOB FROM EMPLOYEES WHERE email = vemail;
return vLOB;
END;
end;
Select PIPELINE.ID as ID,
PIPELINE.CREDIT_RECEIVER as CREDIT_RECEIVER,
PIPELINE.CREATOR as CREATOR,
e1.LOB as CREDIT_RECEIVER_LOB,
e2.LOB as CREATOR_LOB
FROM PIPELINE
LEFT OUTER JOIN EMPLOYEES E1
ON PIPELINE.CREDIT_RECEIVER = EMPLOYEES.EMAIL
LEFT OUTER JOIN EMPLOYEES E2
ON PIPELINE.CREATOR = EMPLOYEES.EMAIL
Ramin Hashimzade
Similar Messages
-
Best way to import data to multiple tables in oracle d.b from sql server
HI All am newbie to Oracle,
What is the Best way to import data to multiple tables in Oracle Data base from sql server?
1)linked server?
2)ssis ?
If possible share me the query to done this task using Linked server?
Regards,
KoteRavindra.check:
http://www.mssqltips.com/sqlservertip/2011/export-sql-server-data-to-oracle-using-ssis/
koteravindra
Handle: koteravindra
Status Level: Newbie
Registered: Jan 9, 2013
Total Posts: 4
Total Questions: 3 (3 unresolved)
why so many unresolved questions? Remember to close your threads marking them as answered. -
Best Way to port the data from one DB to another DB using Biztalk
Hi,
please suggest best way to move the data from one db to another DB using biztalk.
Currently I am doing like that, for each transaction(getting from different source tables) through receive port, and do some mapping (some custom logic for data mapping), then insert to target normalized tables(multiple tables) and back to update the status
of transaction in source table in sourceDB. It is processing one by one.
How/best we we can do it using bulk transfer and update the status. Since it has more than 10000 transaction per call.
Thanks,
VinothHi Vinoth,
For SQL Bulk inserts you can always use SQL Bulk Load
adapter.
http://www.biztalkgurus.com/biztalk_server/biztalk_blogs/b/biztalksyn/archive/2005/10/23/processing-a-large-flat-file-message-with-biztalk-and-the-sqlbulkinsert-adapter.aspx
However, even though a SQL Bulk Load adapter can efficiently insert a large amount of data into SQL you are still stuck with the issues of transmitting the
MessageBox database and the memory issues of dealing with really large messages.
I would personally suggest you to use SSIS, as you have mentioned that records have to be processed in specific time of day as opposed to when the
records are available.
Please refer to this link to get more information about SSIS: http://msdn.microsoft.com/en-us/library/ms141026.aspx
If you have any more questions related to SSIS, please ask it in
SSIS
forum and you will get specific support.
Rachit -
Best way to declare and use internal table
Hi all,
As per my knoledge there are various techeniques (Methods) to declare and use the internal tables.
Please Suggest me the Best way to declaring and using internal table ( WITH EXAMPLE ).
Please Give the reason as well how the particular method is good ?
What are benefits of particular method ?
Thanks in advance.
Regards
RajHello Raj Ahir,
There are so many methods to declare an internal table.
Mainly I would like to explain 2 of them mostly used.
1. Using Work Area and
2. With header line.
This with header line concept is not suggestable, because, when we shift the code to oops concept.. it doesn't work... Because OOPS doesn't support the Headerline concept...
But it all depends on the situation.
If you are sure that your program doen't make use of the OOPs concept, you can use HEADER LINE concept. If it invols OOPs use WORK AREA concept.
Now I'l explain these two methods with an example each...
1. Using Work area.
TABLES: sflight.
DATA: it_sflight TYPE TABLE OF sflight.
DATA: wa_sflight LIKE LINE OF it_sflight.
SELECT *
FROM sflight
INTO it_sflight
WHERE <condition>.
LOOP AT it_sflight INTO wa_sflight.
WRITE / wa_sflight.
ENDLOOP.
In this case we have to transfer data into work area wa_sflight.
We can't access the data from the internal table direclty without work
area.
*<===============================================
2. Using Header line.
DATA: BEGIN OF it_sflight OCCURS 0,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
END OF it_sflight.
SELECT *
FROM sflight
INTO it_sflight
WHERE <condition>.
LOOP AT it_sflight INTO wa_sflight.
WRITE / wa_sflight.
ENDLOOP.
In this case we can directly access the data from the internal table.
Here the internal table name represents the header. for each and every
interation the header line will get filled with new data. If you want to
represnent the internal table body you can use it_sflight[].
*<======================================================
TYPES: BEGIN OF st_sflight,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
END OF st_sflight.
DATA: it_sflight TYPE TABLE OF st_sflight,
wa_sflight LIKE LINE OF it_sflight.
This is using with work area.
DATA: it_sflight LIKE sflight OCCURS 0 WITH HEADER LINE.
This is using header line.
<b>REWARD THE POINTS IF IT IS HELPFUL.</b>
Regards
Sasidhar Reddy Matli.
Message was edited by: Sasidhar Reddy Matli
Sasidhar Reddy Matli -
Best way to remove unwanted signs from string
Which is the best way to purify a string from possible dangerous signs? I want to remove all characters that is not a-z or 0-9? how would I go about?
read the string character by character, and check to
see if they're characters you want to remove or not,
by comparing them to the ascii values of characters
you permit. I've used this before, but I can't
remember what exactly it permits, and I'm too lazy to
look up the ascii table :) But this sort of thing
works.
int c = in.read();
while(c!=-1){
if((c<33)||(c<58&&c>44)){
out.write(c);
I thought about that too. But the values in the ASCII table... arn't they a little volatile to use? I mean, will my application work on other systems or systems with other languages? -
HT3847 How is the best way to separate copied MP3 from AIFF files in my library?
How is the best way to separate duplicate MP3 from AIFF files in my library?
Zice wrote:
I want higher resolution then afforded in the original download.
Then why are you converting iTunes purchases?
You cannot get higher resolution by converting the original. This goes for converting anything, not just iTunes purchases.
Creating an AIFF will simply make the file 10 time as large with zero increase in quality.
Don't really want to debate value of creating the new version.
Agreed.
You are simply wasting time and drive space converting iTunes purchases to AIFF. -
I am moving from PC to Mac. My PC has two internal drives and I have a 3Tb external. What is best way to move the data from the internal drives to Mac and the best way to make the external drive read write without losing data
Paragon even has non-destriuctive conversion utility if you do want to change drive.
Hard to imagine using 3TB that isn't NTFS. Mac uses GPT for default partition type as well as HFS+
www.paragon-software.com
Some general Apple Help www.apple.com/support/
Also,
Mac OS X Help
http://www.apple.com/support/macbasics/
Isolating Issues in Mac OS
http://support.apple.com/kb/TS1388
https://www.apple.com/support/osx/
https://www.apple.com/support/quickassist/
http://www.apple.com/support/mac101/help/
http://www.apple.com/support/mac101/tour/
Get Help with your Product
http://docs.info.apple.com/article.html?artnum=304725
Apple Mac App Store
https://discussions.apple.com/community/mac_app_store/using_mac_apple_store
How to Buy Mac OS X Mountain Lion/Lion
http://www.apple.com/osx/how-to-upgrade/
TimeMachine 101
https://support.apple.com/kb/HT1427
http://www.apple.com/support/timemachine
Mac OS X Community
https://discussions.apple.com/community/mac_os -
Got new macbook pro. What is the best way to transfer my itunes from my old pc to my new mac? I want to be able to plug my iphones and ipad in to new mac and have redo anything
See Here... This should transfer everything...
Move iTunes Library from PC to MAC
http://www.macworld.com/article/146958/2010/03/move_itunes_windows_mac.html -
Best way to transfer DVD videos from laptop to ipad air
Best way to transfer DVD videos from laptop to ipad air
presuming they're not copywriteed commercial dvd's, you can use a program like Handbrake to convert the dvd files to mp4's that you can then import into iTunes and sync to your device.
If they're copywritted commercial dvd's then you'd have to break the copywrite encoding to transcode the files and since that is illegal in the US no one here can help you with that. -
I bought CS6 extended yesterday (yes i did). I have CS4 and lots of photo's in bridge (tagged with keywords). What is the best way to get my photos from bridge cs4 to cs6? Is there a guideline how to go about: so I don't loose any of my photos/keywords? Who can help?
The Bridge General Discussion can give you the specifics of transferring your information over to Bridge CS6.
-
What is the best way to make a DVD from iMovie
What is the best way to make a DVD from iMovie?
I am using iMovie 06 (Naturally) with iDVD 08. I have always used;
iMovie 06, File > Share to iDVD 08. And got pretty good results.
Some say the best way is to quit iMovie 06, open iDVD and import the movie from the Media button.
I have tried both methods in the results look the same. I'm interested in getting the very best quality possible.You likely have one of the most expensive media converter boxes on the market today.
But does it work well with most macs? (my guess is that it does). But more specifically can it "handshake" with an intel based mac? I personally haven't tried it.
But you may want to read this for yourself if you haven't already:
http://discussions.apple.com/thread.jspa?threadID=1179361&tstart=2362
Assuming it works then the best format is .dv which this unit will support apparently. -
What is the best way to completely uninstall Aperture from a MacBook Pro?
What is the best way to completely uninstall Aperture from a MacBook Pro.
I just ordered a new MacBook Pro and I want to remove it from my older MacBook Pro.Deleting the application from your /Applications folder is sufficient. There are sample projects in /Library/Application/Aperture you may want to get rid of as well, as they take up a fair bit of space.
-
What is the best way to filter an IP from being blocked?
What is the best way to filter an IP from being blocked by a false positive? Event Action Filter?
I'll assume you really mean "blocked" as opposed to "denied". You can either create an event action filter and subtract the blocked action, or you can add the address to the "never block" addresses.
-
What is the best way to call a report from within a report
What is the best way to call a report from within a report(master / Detail concept)
A type of drill down report
Oracle Database 10g
Forms 10.1.2.0.2
Report Builder 10.1.2.0.2Hi
Have a look in this link, certainly you will get fix, if not just post a comment on blog, will get reply soon
http://windows7bugs.wordpress.com/?s=oracle+10g+bug -
What is the best way to export a cutterline from photoshop?
What is the best way to export a cutterline from photoshop?
Wie exportiere ich am am besten einen Schnittlinie aus Photoshop? Ich bekomme von einem Wort immer nur den ersten Buchstaben exportiert, obwohl alles gerastert auf einer Ebene liegt.
Thank you! Vielen Dank!What are you talking about exactly?
If you need to export vector data Photoshop is not the first choice but if you have Type Layers (without faux styles), Vector Masks or Paths it is possible.
alles gerastert auf einer Ebene
does not seem to make sense in this context though.
Maybe you are looking for
-
Need to re-add computer to iTunes Match each time I open iTunes
Every time I start up iTunes (10.6.1.7) on my Windows Desktop PC (Windows 7 Home Premium, Service Pack 1, 64 bit), I see the cloud with lightening bolt icon next to the music item in the iTunes Library indicating that iTunes is not connected with iTu
-
Did i post this question in the right place to get an answer?
-
The system I'm running is Scientific Linux. PDF files, I need to open in a browser, are on the file server, but in the same folder as my html files, etc. So, in HTML I gave the link to some PDF to open it in the browser, however, Mozilla says it can'
-
Ticket created on ECC does not show on SM7.0
On ECC PROD, select help->create support message, fill up info and save, a support message is created. Because we have an SM7.0 based CHARM configured for above ECC landscape. The ticket created above should show up at that SM7.0 in txn crm_dno_monit
-
How can I get safari working correctly again?
Ok, I noticed a blue line going up my screen about 6-7 inches, so I decided to look up ways I could possibly get it to go away, now I'm faced with another problem. First I tried just restarting the computer, then I did a "Safe Boot" I believe it was