Selecting Employees and Joins in PL/SQL using IF conditions
how to get empno starts with 7 from emp and jobs is manager and sales manager and clerk those r joined in before 1981 year r in 1981
i want pl/sql code for that one using if conditions
{thread:id=2174552}
{message:id=9360002}
Short answer, read a book
2 Day Developer's Guide
http://docs.oracle.com/cd/E11882_01/appdev.112/e10766/toc.htm
SQL Language Reference
http://docs.oracle.com/cd/E11882_01/server.112/e26088/toc.htm
PL/SQL Language Reference
http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm
Edited by: 3360 on Sep 10, 2012 9:26 AM
Removed inappropriate thread specific text since post was moved by a moderator
Similar Messages
-
Select Distinct and join in ODI
Hi,
I have following task to perform: I am loading metadata into Planning dimension from Oracle database. I have two tables
1. "Sales"
Columns: Name, Number, Value
Sample Data:
Product 1, 10, 200
Product 2, 30, 100,
Product 1, 15, 500
2. P&R
Columns:
Name, Alias
Product 1, SampleSoda1
Product 2, SampleSoda2,
Resource 1, CanForSoda,
Resource 2, CO2
What I need to do is: I have to select name and alias from second table of all products that were sold.
So I need to select distinct Name from Table 1, naxt join it with Table 2 (so I have Name and Alias) and load it to planning.
I am a little confused how to do it.
Any help would be great!
Best regards,
GregHi Greg,
What you can do is either :
- Create a yellow interface with your table Sales as source. Map the name column directly in the target. In the flow tab, click on your target and select "Distinct rows".
- Create a second interface, with your first interface as source. Select the "Use Temporary Interface as Derived Table (Sub-Select)" checkbox.
- Add your second datastore and join it. Or you can use a lookup table.
OR
- Create an interface with Sales and P&R as source (or set P&R as a lookup table).
- Go on the flow tab and select "Distinct rows".
If you've a lot a data in the first table, I would go for the first solution.
Hope it helps.
Regards,
JeromeFr
Edited by: JeromeFr on Feb 14, 2013 9:52 AM
To be more clear in the first step of solution 1 -
I have PhotoShop LE installed on my computer, but have one employee in a family based research operation. Can my employee install PhotoShop LE on her laptop, use my serial number and ID, and be legal?
I guess you have posted on the wrong forum. This forum is for Photoshop Elements and your query seems to be more related to Ps Lightroom.
Anyways, not sure about the legal implications, but technically Adobe allows the users to use the product with same serial number on two machines so as far as you have a valid and legitimate serial number registered in your name, YOU can use the product on two machines.
I am although slightly confused when you say "1 employee..." and "not be for commercial use..". -
Select Query and Join Between int and Numeric(22)
I have two tables
tablea
Field1 int
tableb
Field1 Numeric(22)
I know this design is wrong but this is what I have ?
tablea contains about 12M records
Field1 in tablea is one to one related to Field1 in tableb
Now I have Select Query
Select tablea.* from tablea,tableb where tablea.field1=tableb.field1 and tableb.field2 > somrthing
Query here is
Does Join Between
int typeYes, avinash said rightly.
there is another way bit diffict.
use the indexes properly as available in the mseg table and mkpf table even then it is diffcult
else try using BAPI.
some bapi will give the entire details of the MATERAIL DOCUMENT
go to BAPI explorer tcode BAPI.
where you can find the BAPI name like the 'GET_LIST'.
Try this.
hope this will serve your purpose.
Thanks and regards
Ramchander Rao.K -
Hi All,
I had to modify the current select query coz its taking a lot of database time, please suggest the best solution for the below.
SELECT msegbukrs mkpfbudat mkpf~bldat
msegebeln mkpfxblnr mseg~mblnr
msegmjahr msegzeile mseg~xauto
msegparent_id msegwerks mseg~umwrk
msegumlgo msegparent_id ekko~reswk
msegwerks mseglgort mseg~matnr
msegerfmg msegerfme mseg~shkzg
msegsjahr msegsmbln mseg~smblp
msegcharg ekkobedat
INTO TABLE g_tbl_main
FROM mkpf JOIN mseg
ON mkpfmandt = msegmandt AND
mkpfmblnr = msegmblnr AND
mkpfmjahr = msegmjahr
JOIN ekko ON msegmandt = ekkomandt AND
msegebeln = ekkoebeln
JOIN likp ON mkpfxblnr = likpvbeln
CLIENT specified
WHERE mkpf~mandt = sy-mandt AND
mkpf~budat IN s_budat AND
ekko~bedat IN s_bedat AND
mseg~ebeln IN s_ebeln AND
mkpf~xblnr IN s_vbeln AND
likp~vstel IN s_vstel AND
ekko~reswk IN s_reswk AND
mseg~werks IN r_werks AND
mseg~lgort IN s_lgort AND
mseg~matnr IN s_matnr AND
mseg~smbln = space AND
mseg~bwart IN s_bwart AND
mseg~kzzug = c_true.Yes, avinash said rightly.
there is another way bit diffict.
use the indexes properly as available in the mseg table and mkpf table even then it is diffcult
else try using BAPI.
some bapi will give the entire details of the MATERAIL DOCUMENT
go to BAPI explorer tcode BAPI.
where you can find the BAPI name like the 'GET_LIST'.
Try this.
hope this will serve your purpose.
Thanks and regards
Ramchander Rao.K -
Getting first and last records of sql using a analytical function query
hi all!
Thanks in advance for looking at my problem! I have a query that runs against a table that keep all records
of changes on another table (journal table kind of thing). I wrote a sql that would tell what the status of that
requisition was, what came next and its respective dates. However, that would bring a lot of rows. I only need
to see the first row and last couple say 3 last rows. How could I achieve that?
SELECT ano yr,
numero id,
jn_datetime,
status_siafi status,
lead(status_siafi) over(PARTITION BY ano, numero ORDER BY jn_datetime) next_status,
lead(jn_datetime) over(PARTITION BY ano, numero ORDER BY jn_datetime) date_next_status,
MAX(jn_datetime) over(PARTITION BY ano, numero) last_update,
MIN(jn_datetime) over(PARTITION BY ano, numero) first_update
FROM nl_compensado_jn
WHERE ano = '08'
AND numero = '113747'
GROUP BY ano,
numero,
jn_datetime,
status_siafi
YR ID JN_DATETI S N DATE_NEXT LAST_UPDA FIRST_UPD
08 113747 11-SEP-08 1 2 11-SEP-08 20-NOV-08 11-SEP-08
08 113747 11-SEP-08 2 3 12-SEP-08 20-NOV-08 11-SEP-08
08 113747 12-SEP-08 3 2 12-SEP-08 20-NOV-08 11-SEP-08
08 113747 12-SEP-08 2 3 15-SEP-08 20-NOV-08 11-SEP-08
08 113747 15-SEP-08 3 2 15-SEP-08 20-NOV-08 11-SEP-08
08 113747 15-SEP-08 2 3 16-SEP-08 20-NOV-08 11-SEP-08
08 113747 16-SEP-08 3 2 16-SEP-08 20-NOV-08 11-SEP-08
08 113747 16-SEP-08 2 3 17-SEP-08 20-NOV-08 11-SEP-08
08 113747 17-SEP-08 3 2 17-SEP-08 20-NOV-08 11-SEP-08
08 113747 17-SEP-08 2 3 18-SEP-08 20-NOV-08 11-SEP-08
08 113747 18-SEP-08 3 2 18-SEP-08 20-NOV-08 11-SEP-08
08 113747 18-SEP-08 2 3 19-SEP-08 20-NOV-08 11-SEP-08
08 113747 19-SEP-08 3 2 19-SEP-08 20-NOV-08 11-SEP-08
08 113747 19-SEP-08 2 3 23-SEP-08 20-NOV-08 11-SEP-08
08 113747 23-SEP-08 3 2 24-SEP-08 20-NOV-08 11-SEP-08
08 113747 24-SEP-08 2 3 25-SEP-08 20-NOV-08 11-SEP-08
08 113747 25-SEP-08 3 2 25-SEP-08 20-NOV-08 11-SEP-08
08 113747 25-SEP-08 2 3 26-SEP-08 20-NOV-08 11-SEP-08
08 113747 26-SEP-08 3 2 26-SEP-08 20-NOV-08 11-SEP-08
08 113747 26-SEP-08 2 3 29-SEP-08 20-NOV-08 11-SEP-08
08 113747 29-SEP-08 3 2 29-SEP-08 20-NOV-08 11-SEP-08
08 113747 29-SEP-08 2 3 02-OCT-08 20-NOV-08 11-SEP-08
08 113747 02-OCT-08 3 2 02-OCT-08 20-NOV-08 11-SEP-08
08 113747 02-OCT-08 2 3 03-OCT-08 20-NOV-08 11-SEP-08
08 113747 03-OCT-08 3 2 03-OCT-08 20-NOV-08 11-SEP-08
08 113747 03-OCT-08 2 3 06-OCT-08 20-NOV-08 11-SEP-08
08 113747 06-OCT-08 3 2 06-OCT-08 20-NOV-08 11-SEP-08
08 113747 06-OCT-08 2 3 07-OCT-08 20-NOV-08 11-SEP-08
08 113747 07-OCT-08 3 2 07-OCT-08 20-NOV-08 11-SEP-08
08 113747 07-OCT-08 2 3 08-OCT-08 20-NOV-08 11-SEP-08
08 113747 08-OCT-08 3 2 08-OCT-08 20-NOV-08 11-SEP-08
08 113747 08-OCT-08 2 3 09-OCT-08 20-NOV-08 11-SEP-08
08 113747 09-OCT-08 3 2 09-OCT-08 20-NOV-08 11-SEP-08
08 113747 09-OCT-08 2 3 10-OCT-08 20-NOV-08 11-SEP-08
08 113747 10-OCT-08 3 2 14-OCT-08 20-NOV-08 11-SEP-08
08 113747 14-OCT-08 2 3 15-OCT-08 20-NOV-08 11-SEP-08
08 113747 15-OCT-08 3 2 15-OCT-08 20-NOV-08 11-SEP-08
08 113747 15-OCT-08 2 3 16-OCT-08 20-NOV-08 11-SEP-08
08 113747 16-OCT-08 3 2 16-OCT-08 20-NOV-08 11-SEP-08
08 113747 16-OCT-08 2 3 17-OCT-08 20-NOV-08 11-SEP-08
08 113747 17-OCT-08 3 2 17-OCT-08 20-NOV-08 11-SEP-08
08 113747 17-OCT-08 2 3 21-OCT-08 20-NOV-08 11-SEP-08
08 113747 21-OCT-08 3 2 21-OCT-08 20-NOV-08 11-SEP-08
08 113747 21-OCT-08 2 3 22-OCT-08 20-NOV-08 11-SEP-08
08 113747 22-OCT-08 3 2 22-OCT-08 20-NOV-08 11-SEP-08
08 113747 22-OCT-08 2 3 23-OCT-08 20-NOV-08 11-SEP-08
08 113747 23-OCT-08 3 2 23-OCT-08 20-NOV-08 11-SEP-08
08 113747 23-OCT-08 2 3 27-OCT-08 20-NOV-08 11-SEP-08
08 113747 27-OCT-08 3 2 27-OCT-08 20-NOV-08 11-SEP-08
08 113747 27-OCT-08 2 3 28-OCT-08 20-NOV-08 11-SEP-08
08 113747 28-OCT-08 3 2 28-OCT-08 20-NOV-08 11-SEP-08
08 113747 28-OCT-08 2 3 29-OCT-08 20-NOV-08 11-SEP-08
08 113747 29-OCT-08 3 2 29-OCT-08 20-NOV-08 11-SEP-08
08 113747 29-OCT-08 2 3 30-OCT-08 20-NOV-08 11-SEP-08
08 113747 30-OCT-08 3 2 30-OCT-08 20-NOV-08 11-SEP-08
08 113747 30-OCT-08 2 3 31-OCT-08 20-NOV-08 11-SEP-08
08 113747 31-OCT-08 3 2 31-OCT-08 20-NOV-08 11-SEP-08
08 113747 31-OCT-08 2 3 03-NOV-08 20-NOV-08 11-SEP-08
08 113747 03-NOV-08 3 2 03-NOV-08 20-NOV-08 11-SEP-08
08 113747 03-NOV-08 2 3 06-NOV-08 20-NOV-08 11-SEP-08
08 113747 06-NOV-08 3 2 06-NOV-08 20-NOV-08 11-SEP-08
08 113747 06-NOV-08 2 3 07-NOV-08 20-NOV-08 11-SEP-08
08 113747 07-NOV-08 3 2 07-NOV-08 20-NOV-08 11-SEP-08
08 113747 07-NOV-08 2 3 10-NOV-08 20-NOV-08 11-SEP-08
08 113747 10-NOV-08 3 2 10-NOV-08 20-NOV-08 11-SEP-08
08 113747 10-NOV-08 2 3 12-NOV-08 20-NOV-08 11-SEP-08
08 113747 12-NOV-08 3 2 12-NOV-08 20-NOV-08 11-SEP-08
08 113747 12-NOV-08 2 3 13-NOV-08 20-NOV-08 11-SEP-08
08 113747 13-NOV-08 3 2 13-NOV-08 20-NOV-08 11-SEP-08
08 113747 13-NOV-08 2 3 14-NOV-08 20-NOV-08 11-SEP-08
08 113747 14-NOV-08 3 2 14-NOV-08 20-NOV-08 11-SEP-08
08 113747 14-NOV-08 2 3 17-NOV-08 20-NOV-08 11-SEP-08
08 113747 17-NOV-08 3 2 17-NOV-08 20-NOV-08 11-SEP-08
08 113747 17-NOV-08 2 3 18-NOV-08 20-NOV-08 11-SEP-08
08 113747 18-NOV-08 3 2 18-NOV-08 20-NOV-08 11-SEP-08
08 113747 18-NOV-08 2 2 18-NOV-08 20-NOV-08 11-SEP-08
08 113747 18-NOV-08 2 3 19-NOV-08 20-NOV-08 11-SEP-08
08 113747 19-NOV-08 3 2 19-NOV-08 20-NOV-08 11-SEP-08
08 113747 19-NOV-08 2 4 20-NOV-08 20-NOV-08 11-SEP-08
08 113747 20-NOV-08 4 20-NOV-08 11-SEP-08
80 rows selected.thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!
gleisson henriquesorry!!!!! didn't notice that major detail!!!
insert into nl_compensado_jn values ('INS','LETICIA','11-SEP-08 15:08:27','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','1','');
insert into nl_compensado_jn values ('UPD','BELLA','19-SEP-08 07:43:20','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','18-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','15-SEP-08 07:45:54','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','12-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','11-SEP-08 15:34:30','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','11-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','16-SEP-08 13:48:38','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','16-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','18-SEP-08 07:44:12','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','17-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','16-SEP-08 07:38:29','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','15-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','19-SEP-08 16:13:20','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','19-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','18-SEP-08 15:33:59','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','18-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','15-SEP-08 15:35:52','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','15-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','02-OCT-08 07:51:38','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','29-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','26-SEP-08 08:11:04','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','25-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','29-SEP-08 15:46:31','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','29-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','29-SEP-08 12:12:29','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','26-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','08-OCT-08 07:44:06','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','07-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','09-OCT-08 07:44:43','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','08-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','03-OCT-08 07:44:57','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','02-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','06-OCT-08 07:41:19','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','03-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','17-SEP-08 07:35:00','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','16-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','03-OCT-08 15:17:09','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','03-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','23-SEP-08 16:05:01','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','19-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','25-SEP-08 07:37:44','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','24-SEP-08');
insert into nl_compensado_jn values ('UPD','GERENTE','26-SEP-08 15:57:35','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','26-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','24-SEP-08 15:31:40','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','24-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','12-SEP-08 08:02:34','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','11-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','09-OCT-08 15:04:27','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','09-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','17-SEP-08 15:31:46','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','17-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','07-OCT-08 07:51:57','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','06-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','07-OCT-08 15:04:54','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','07-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','02-OCT-08 15:49:48','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','02-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','25-SEP-08 15:36:45','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','25-SEP-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','06-OCT-08 15:00:08','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','06-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','08-OCT-08 14:57:23','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','08-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','12-SEP-08 15:31:47','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','12-SEP-08');
insert into nl_compensado_jn values ('UPD','BELLA','06-NOV-08 10:04:08','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','03-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','10-NOV-08 14:11:55','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','07-NOV-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','23-OCT-08 15:08:23','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','23-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','31-OCT-08 14:59:36','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','31-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','28-OCT-08 10:33:59','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','27-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','16-OCT-08 08:01:41','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','15-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','29-OCT-08 11:04:35','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','28-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','17-OCT-08 07:58:07','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','16-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','22-OCT-08 10:36:15','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','21-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','21-OCT-08 13:08:38','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','17-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','23-OCT-08 10:49:52','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','22-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','27-OCT-08 10:12:47','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','23-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','16-OCT-08 15:36:47','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','16-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','14-OCT-08 15:19:24','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','14-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','03-NOV-08 09:10:26','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','31-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','15-OCT-08 07:59:37','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','14-OCT-08');
insert into nl_compensado_jn values ('UPD','ANTUNES','10-OCT-08 11:25:23','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','09-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','03-NOV-08 16:01:49','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','03-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','29-OCT-08 15:13:36','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','29-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','22-OCT-08 15:25:48','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','22-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','30-OCT-08 10:22:24','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','29-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','30-OCT-08 15:15:47','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','30-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','17-OCT-08 15:19:19','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','17-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','06-NOV-08 16:08:43','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','06-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','31-OCT-08 10:42:10','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','30-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','07-NOV-08 16:01:50','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','07-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','21-OCT-08 15:34:07','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','21-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','27-OCT-08 15:22:24','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','27-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','28-OCT-08 15:16:19','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','28-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','15-OCT-08 15:15:54','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','15-OCT-08');
insert into nl_compensado_jn values ('UPD','BELLA','07-NOV-08 09:39:43','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','06-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','17-NOV-08 09:29:29','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','14-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','12-NOV-08 09:40:53','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','10-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','18-NOV-08 09:49:53','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','17-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','19-NOV-08 15:29:15','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084810','16660','2','19-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','10-NOV-08 15:25:03','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','10-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','13-NOV-08 09:10:07','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','12-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','14-NOV-08 10:33:24','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','3','13-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','12-NOV-08 15:32:54','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','12-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','17-NOV-08 15:37:10','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','17-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','19-NOV-08 09:14:38','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084810','16660','3','18-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','20-NOV-08 09:06:16','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084810','16660','4','19-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','14-NOV-08 15:19:03','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','14-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','18-NOV-08 15:47:14','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','18-NOV-08');
insert into nl_compensado_jn values ('UPD','BELLA','13-NOV-08 15:29:06','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084110','16660','2','13-NOV-08');
insert into nl_compensado_jn values ('UPD','HEBER','18-NOV-08 18:41:45','','TRIGER25','','08','113747','00','00003','84110','08','DV','540638','11-SEP-08','WX01208201001760084810','16660','2','18-NOV-08'); -
Can't select text and scroll when using Word
Recently I have been unable to select text and scroll down the page using two fingers, while in a word document.This is only happening in Word, so far no other programs. Does anyone have an idea of how to turn on or off this feature?
I cant scroll below or above viewable section of text in any of my Macbooks, iMac, Mac Mini. Never have been able to, never could, except by pressing the arrow keys whilst selecting, to move up or down.
Its stupid
I dont have flash installed (never will do since my first virus of video ad sound running in background from Cnet was downloaded and kept returning until i deinstalled flash).
I believe that this is a universal issue because none of my Macs can scroll out of screen when selecting text, which as a webmaster and developer, is a pain in the butt
My issue is not in word documents, its in everything -
I am running Windows 7 and using iTunes 11. I have an iPhone 4.
In the past I have been able to sync selected albums and audiobooks with my iPhone using iTunes with no problems, but today when I tried to add an audiobook from my computer to my iPhone, I could not see it (or the audiobooks previously added to my iPhone) listed as a choice under Books --> Sync Audiiobooks --> Selected Audiobooks.
I connected my iPhone to my laptop via USB. iTunes 11 comes up. My iPhone syncs automatically.
I click the iPhone device in the sidebar and the list of choices (Summary, Info, Apps, Tones, Music, Movies, TV Shows, Books, and Photos) appears across the top of the main part of iTunes to the right of the sidebar.
When I click on Music from this list of choices, I have selected Sync Music and Selected playlists, artists, albums, and genres.
Under this I see my list of Playlists and the ones I have checked. I also see my list of Artists and the ones I have checked.
Under these two items, I see the words Genres and Albums, but I cannot scroll down to see them (not even to see the ones I have previously selected to be synched with my iPhone).
When I click on Books I see that Sync Audiobooks is checked and Selected audiobooks is selected, but I cannot see the list of audiobooks from which I can choose the ones I want to add to my iPhone and I cannot see the audiobooks that I previously selected and that are currently on my iPhone. I see the words Audiobooks and Parts, but I cannot scroll below these words to see the list of audiobooks that are on my laptop.
Any help in resolving these issues would be greatly appreciated.
Thanks.
Eddiehttp://www.technipages.com/iphone-ipad-ipod-touch-enable-disable-shuffle-mode.ht ml
I think you've tried that though.
I had similar issue a few months ago - I think it didn't work unless I did it when the music was actually playing in the now playing section. -
Using Case and Joins in update statement
Hi all,
I need to update one column in my table...but need to use case and joins...I wrote the query and it is not working
I am getting an error msg saying...the SQL command not ended properly...
I am not that good at SQL...Please help...
update t1 a
set a.name2=
(case
when b.msg2 in ('bingo') then '1'
when b.msg2 in ('andrew') then '2'
when b.msg2 in ('sam') then '3'
else '4'
end )
from t1 a left outer join t2 b
on a.name1 = b.msg1 ;
Waiting for help on this...!
Thanks in Advance... :)Another approach is to update an inline view defining the join:
update
( select a.name2, b.msg2
from t1 a
join t2 b on b.msg1 = a.name1 ) q
set q.name2 =
case
when q.msg2 = 'bingo' then '1'
when q.msg2 = 'andrew' then '2'
when q.msg2 = 'sam' then '3'
else '4'
end;which could also be rewritten as
update
( select a.name2
, case q.msg2
when 'bingo' then '1'
when 'andrew' then '2'
when 'sam' then '3'
else '4'
end as new_name
from t1 a
join t2 b on b.msg1 = a.name1 ) q
set name2 = new_name;The restriction is that the lookup (in this case, t2.msg1) has to be declared unique, via either a primary or unique key or unique index.
(You don't strictly need to give the view an alias, but I used 'q' in case you tried 'a' or 'b' and wondered why they weren't recognised outside the view.) -
Hi
I want to know when is good to do join between 2 tables
or to do select and loop and in the loop select single
When it good to use for all entries
Thanks
have a nice dayHi
JOIN is faster to fetch the data from database tables provided they have some connecting fields in both tables
for all entries
The WHERE clause of the SELECT statement has a special variant that allows you to derive conditions from the lines and columns of an internal table:
SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...
<cond> may be formulated as described above. If you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.
The internal table <itab> must have a structured line type, and each field that occurs in the condition <cond> must be compatible with the column of the database with which it is compared. Do not use the operators LIKE, BETWEEN, and IN in comparisons using internal table fields. You may not use the ORDER BY clause in the same SELECT statement.
You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.
Select single and Upto 1 rows
Difference Between Select Single and Select UpTo One Rows
According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.
select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.
The best way to find out is through sql trace or runtime analysis.
Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.
The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
Mainly: to read data from
The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
Mainly: to check if entries exist.
Reward points for useful Answers
Regards
Anji -
Select and join one month record
I receive a request from my customer . He want generate a total sales record for a month and those data stored in daily sales table and customer table.
tblcustomer-20140101
tblcustomer-20140102
tblcustomer-20140103
tblcustomer-20141231
tblsales-20140101
tblsales-20140102
tblsales-20140103
tblsales-20141231
is there anyway when user select month name from application(ex: April), it will choose all april record and join it together?Hi kjleong,
Generally to say, it is not a good practice to store the same entity data individually for each day, there are many shortages, such as the problem you posted in this thread. You can put all of them into one table and tag them with a DATE column. Anyway
in this case, to achieve your requirement, you may refer the below stored procedure(SP).
CREATE PROC ProcGetSales
@Year VARCHAR(20),
@Month VARCHAR(20)
AS
DECLARE @Date DATE;
DECLARE @Days INT;
DECLARE @SqlStr NVARCHAR(MAX);
SET @Date = @Year+'-'+@Month+'-01';
SET @Days = DATEDIFF(DAY,@Date,DATEADD(MM,1,@Date)); --get the days of the specific month
create a temp table
CREATE TABLE #Temp
col1 int --you should put the columns after join in your real envrioment here
table join statement, put the join result into a temp table
I dont know the columns so I use * here and the join condition is just based on assumption
you should modify the statement basing on your real environment
SET @SqlStr= 'INSERT INTO #Temp SELECT * FROM [tblcustomer-WhichDay] tc JOIN [tblsales-WhichDay] ts ON tc.customerID = ts.customerID';
DECLARE @Counter INT = 1;
WHILE @Counter <= @Days --loop the tables named after the specific month
BEGIN
DECLARE @Sql NVARCHAR(MAX) = REPLACE(@SqlStr,'WhichDay',CONVERT(VARCHAR(8),CAST(@Year+'-'+@Month+'-'+LTRIM(STR(@Counter)) AS DATE),112));
EXEC sp_executesql @Sql;
SET @Counter = @Counter+1;
END
SELECT * FROM #TEMP
The SP is not ready to use, you have to make some modification basing on your real environment before it works.
If you have any question, feel free to let me know.
Best regards,
Eric Zhang
If you have any feedback on our support, please click
here. -
Bind Variable in SELECT statement and get the value in PL/SQL block
Hi All,
I would like pass bind variable in SELECT statement and get the value of the column in Dynamic SQL
Please seee below
I want to get the below value
Expected result:
select distinct empno ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
100, HR
select distinct ename ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
TEST, HR
select distinct loc ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
NYC, HR
Using the below block I am getting column names only not the value of the column. I need to pass that value(TEST,NYC..) into l_col_val variable
Please suggest
----- TABLE LIST
CREATE TABLE EMP(
EMPNO NUMBER,
ENAME VARCHAR2(255),
DEPT VARCHAR2(255),
LOC VARCHAR2(255)
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (100,'TEST','HR','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (200,'TEST1','IT','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (300,'TEST2','MR','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (400,'TEST3','HR','DTR');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (500,'TEST4','HR','DAL');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (600,'TEST5','IT','ATL');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (700,'TEST6','IT','BOS');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (800,'TEST7','HR','NYC');
COMMIT;
CREATE TABLE COLUMNAMES(
COLUMNAME VARCHAR2(255)
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('EMPNO');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('ENAME');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('DEPT');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('LOC');
COMMIT;
CREATE TABLE DEPT(
DEPT VARCHAR2(255),
DNAME VARCHAR2(255)
INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('HR','HUMAN RESOURCE');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('MR','MARKETING');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
COMMIT;
PL/SQL BLOCK
DECLARE
TYPE EMPCurTyp IS REF CURSOR;
v_EMP_cursor EMPCurTyp;
l_col_val EMP.ENAME%type;
l_ENAME_val EMP.ENAME%type;
l_col_ddl varchar2(4000);
l_col_name varchar2(60);
l_tab_name varchar2(60);
l_empno number ;
b_l_col_name VARCHAR2(255);
b_l_empno NUMBER;
begin
for rec00 in (
select EMPNO aa from EMP
loop
l_empno := rec00.aa;
for rec in (select COLUMNAME as column_name from columnames
loop
l_col_name := rec.column_name;
begin
l_col_val :=null;
l_col_ddl := 'select distinct :b_l_col_name ,pr.dept ' ||' from emp pr, dept ps where ps.dept like ''%IT'' '||' and pr.empno =:b_l_empno';
dbms_output.put_line('DDL ...'||l_col_ddl);
OPEN v_EMP_cursor FOR l_col_ddl USING l_col_name, l_empno;
LOOP
l_col_val :=null;
FETCH v_EMP_cursor INTO l_col_val,l_ename_val;
EXIT WHEN v_EMP_cursor%NOTFOUND;
dbms_output.put_line('l_col_name='||l_col_name ||' empno ='||l_empno);
END LOOP;
CLOSE v_EMP_cursor;
END;
END LOOP;
END LOOP;
END;user1758353 wrote:
Thanks Billy, Would you be able to suggest any other faster method to load the data into table. Thanks,
As Mark responded - it all depends on the actual data to load, structure and source/origin. On my busiest database, I am loading on average 30,000 rows every second from data in external files.
However, the data structures are just that - structured. Logical.
Having a data structure with 100's of fields (columns in a SQL table), raise all kinds of questions about how sane that structure is, and what impact it will have on a physical data model implementation.
There is a gross misunderstanding by many when it comes to performance and scalability. The prime factor that determines performance is not how well you code, what tools/language you use, the h/w your c ode runs on, or anything like that. The prime factor that determines perform is the design of the data model - as it determines the complexity/ease to use the data model, and the amount of I/O (the slowest of all db operations) needed to effectively use the data model. -
Dynamic From statement in select query and/or outer join not working
Dear Experts, I have a select query where the select columns are dynamic, the where condition is also dynamic. It is of the below format:
Select (dynamic columns) INTO <wa>
FROM a inner join b on af1 = bf1
inner join c on af2 = cf2......
WHERE (dynamic conditios)
ORDER BY ( dynamic sort condition).
Now I have to include some tables (dynamically depending on the user input) in the inner join statement which will give description for the selected fields. And these database tables may or may no be empty. So in this case, my select query will not return any data if these tables are empty. And I dont want that.
I tried using outer join for the extra tables but it gave me a runtime error. I also tried forming the inner join statement dynamically but it was not supporting.
Kindly give me pointers.
ThanksHey thanks for the reply, but the problem is not solved.
I am already using ( fileds, value) like table in my where condition and the select statement was working properly.
the problem is that now I have to include some tables in the join statement which can be empty and so i want to use Outer join.
But I am getting a runtime error as below:
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SYNTAX', was not
caught in
procedure "ZATSCSNG_RFC_READ_TABLE" "(FUNCTION)", nor was it propagated by a
RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
The running ABAP program wanted to execute a SELECT statement whose
WHERE condition was (partly) specified dynamically. The part that is
specified in an internal table at runtime is compared to a field of the
right table of an LEFT OUTER JOIN. Such comparisons are not supported by
all database systems and are therefore not allowed. -
Why can't I use the Average and Join commands in an action?
Something I do a hundred times a day is select two endpoints, average them, and join them. I tried to make an action and map it to an Fkey, but Illustrator won't allow the Average or Join commands in an action. When I tried using the Insert Menu Command, it made Illustrator crash. Finally I managed to do it without Illustrator crashing, but there is then no way to hit "OK" in the Average dialog box via the Actions palette. Why is this apparently impossible?
You have to use Actions Palette Flyout menu >> insert menu item to get those menu items reocorded.
To get action to stop crashing you need to Actions Palette Flyout menu >> Playback Options >> 1 sec or greater.
There already are keyboard commands CMD J & OPT CMD J for these. Unfotunately you cannot record for example the next menu choice step such as BOTH. A script likely could be written for this though, and you can try posting in the Illustrator scripting forum. -
Hash semi join and join selectivity
Hi,
I'm looking for an explanation of the rule-of-thumb that hash joins are more efficient for high selectivity joins.
If I have a query with two tables, semi-joined together using an EXISTS clause, why would a hash join be better for a high selectivity join as opposed to a low selectivity join?
To clarify, my definition of selectivity is:
selectivity = # of rows returned / # of rows processed
Or in more database specific terms:
selectivity = num_rows/cardinality
Selectivity is a value between 0 and 1, so by high selectivity, I mean a selectivity value closer to 1.
Thanks for any input.
- KRkenny r. wrote:
Hi,
I'm looking for an explanation of the rule-of-thumb that hash joins are more efficient for high selectivity joins.
If I have a query with two tables, semi-joined together using an EXISTS clause, why would a hash join be better for a high selectivity join as opposed to a low selectivity join?
To clarify, my definition of selectivity is:
selectivity = # of rows returned / # of rows processed
Or in more database specific terms:
selectivity = num_rows/cardinality
Selectivity is a value between 0 and 1, so by high selectivity, I mean a selectivity value closer to 1.KR,
the question is "more efficient" than ... what?
A hash join is usually the most efficient operation if you have to join a large set or two large sets. Often the hash join operation performs full table scans as part of the join operation, but not necessarily.
The cost of the hash join depends on the volume to join, the available memory and the resulting operation (optimal / one-pass / multi-pass). If the hash table can be kept in memory then it's simply the cost to read the first data set used as hash table, the cost of reading the probe table and the CPU cost of processing the hash join. If the hash table doesn't fit into memory, it depends on how often the build (hash) table and probe data needs to be read (one-pass / multi-pass) to perform the join with the hash table.
If you have a "low selectivity" join, and I assume you mean that the join actually filters out many rows by "low selectivity", then other join operations might be more effective, like a NESTED LOOP that uses the smaller table to iterate via an index access over the second table, selectively picking the rows corresponding to the first table. Depending on the number of iterations and the number of rows of the second table to process per iteration this can be very efficient, but tends to be very inefficient if the iterations and/or number of rows in second table is significantly larger than estimated.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/
Maybe you are looking for
-
SSO using SAML2 in WebLogic Server 10.3 not working
Dear all, I have tried all possible configuration to configure SSO but with no hope :( My requirement is to configure SSO using SAML2, weblogic 10.3 and 1 domain. I followed the following links in my configuration: 1- http://biemond.blogspot.com/2009
-
Assigning a song to multiple albums
I've been collecting a nice library by now and I really like iTunes, but there is one thing not present (or I can't find it). The option to assign a song to multiple albums, I have a lot of physical CD's digitalized in iTunes and almost a quarter of
-
Create a Report for Demo_Orders (2 Day Plus Application Express Developer )
Hello, I will make a Report for Demo_Orders and I have a problem. I made step by step 1. On the Application home page, click Create Page. 2. Select the page type Report and click Next. 3. Select Wizard Report and click Next. 4. For Page Attributes: a
-
Help regarding applet for querying client's MAC?
Please help with an applet and java code that uses Runtime.getRuntime().exec("ipconfig -all") and gets the client's machine MAC address? If any one already worked with applets for querying client mahchine MAC , please give me a solution.
-
ESS Leave Request - Customer fields default function not working
Hi, a. SAP version being discussed SAP ECC6.0 EP7.0 ESS/MSS b. Here is the scenario 1. We are using ESS Leave Request application for employees to request leave. We are using the standard web dynpro java leave request application delivered by SAP. 2.