Can we make this query shorter....?
hi there
Can any body help me in reducing the number of lines in this query ! I am using union to concat 3 queries. Select fields in every query are same and in where condition also most of the joins are same in every query. but in where clause only two conditions are different. Can we make this 3 queries into one becoze entire select statement fields are same and most of the where conditions are same !
Below is the query:
SELECT
au1.bu_id,
au1.first_nam,
au1.last_nam,
c.id,
c.first_nam_d,
c.last_nam_d,
c.birth_dte_d,
c.ssn_num_d,
se.id schd_event_id,
seu.dsc,
ssc.dsc,
sea.access_typ,
sea.ATTENDEE_TYP
FROM
CLIENT c,
APP_USER au1,
SCHD_STAT_CD ssc,
schd_event_url seu,
schd_evnt se,
SCHD_evnt_stat ses,
SCHD_EVNT_ATTENDEE sea,
CLIENT_APPT ca
WHERE
c.id = ca.client_id_k AND
au1.bu_id = se.APP_USER_BU_ID_PRIME_K AND
ssc.code = ses.SCHD_STAT_CD_CODE_K AND
seu.code = se.SCHD_EVNT_URL_CODE_K AND
se.id = ses.SCHD_EVNT_ID_K AND
se.id = sea.SCHD_EVNT_ID_K(+) AND
se.id = ca.SCHD_EVNT_ID_K AND
sea.ATTENDEE_TYP(+) = 'WORKER' AND
ses.create_ts = (select max(create_ts) FROM SCHD_evnt_stat ses1 WHERE ses1.SCHD_EVNT_ID_K = ses.SCHD_EVNT_ID_K)
UNION
SELECT
au1.bu_id,
au1.first_nam,
au1.last_nam,
c.id,
c.first_nam_d,
c.last_nam_d,
c.birth_dte_d,
c.ssn_num_d,
se.id schd_event_id,
seu.dsc,
ssc.dsc,
FROM
CLIENT c,
APP_USER au1,
SCHD_STAT_CD ssc,
schd_event_url seu,
schd_evnt se,
SCHD_evnt_stat ses,
SCHD_EVNT_ATTENDEE sea,
CLIENT_APPT ca
WHERE
c.id = ca.client_id_k AND
au1.bu_id = se.APP_USER_BU_ID_PRIME_K AND
ssc.code = ses.SCHD_STAT_CD_CODE_K AND
seu.code = se.SCHD_EVNT_URL_CODE_K AND
se.id = ses.SCHD_EVNT_ID_K AND
se.id = sea.SCHD_EVNT_ID_K AND
se.id = ca.SCHD_EVNT_ID_K AND
sea.ATTENDEE_TYP = 'ROLE' AND
ses.create_ts = (select max(create_ts) FROM SCHD_evnt_stat ses1 WHERE ses1.SCHD_EVNT_ID_K = ses.SCHD_EVNT_ID_K)
UNION
SELECT
au1.bu_id,
au1.first_nam,
au1.last_nam,
c.id,
c.first_nam_d,
c.last_nam_d,
c.birth_dte_d,
c.ssn_num_d,
se.id schd_event_id,
seu.dsc,
ssc.dsc,
sea.access_typ,
sea.ATTENDEE_TYP
FROM
CLIENT c,
APP_USER au1,
SCHD_STAT_CD ssc,
schd_event_url seu,
schd_evnt se,
SCHD_evnt_stat ses,
SCHD_EVNT_ATTENDEE sea,
CLIENT_APPT ca
WHERE
c.id = ca.client_id_k AND
au1.APP_ROLE_NAM_DESKTOP_K = sea.ATTENDEE_ID_K AND
ssc.code = ses.SCHD_STAT_CD_CODE_K AND
seu.code = se.SCHD_EVNT_URL_CODE_K AND
se.id = ses.SCHD_EVNT_ID_K AND
se.id = sea.SCHD_EVNT_ID_K AND
se.id = ca.SCHD_EVNT_ID_K AND
sea.ATTENDEE_TYP = 'ROLE' AND
ses.create_ts = (select max(create_ts) FROM SCHD_evnt_stat ses1 WHERE ses1.SCHD_EVNT_ID_K = ses.SCHD_EVNT_ID_K)
Thanks in advance
prasanth a.s.
Hi,
it is difficult to change this query without the possibility to test it in a worksheet. But try the following query.
I think it should be the same result as your 3 queries.
SELECT au1.bu_id,
au1.first_nam,
au1.last_nam,
c.id,
c.first_nam_d,
c.last_nam_d,
c.birth_dte_d,
c.ssn_num_d,
se.id schd_event_id,
seu.dsc,ssc.dsc,
decode(sea.access_typ,NULL,' ',sea.access_typ) AS sea.access_typ,
decode(sea.ATTENDEE_TYP,NULL,' ',sea.ATTENDEE_TYP) AS sea.ATTENDEE_TYP
FROM CLIENT c,
APP_USER au1,
SCHD_STAT_CD ssc,
schd_event_url seu,
schd_evnt se,
SCHD_evnt_stat ses,
SCHD_EVNT_ATTENDEE sea,
CLIENT_APPT ca
WHERE c.id = ca.client_id_k
AND au1.bu_id = se.APP_USER_BU_ID_PRIME_K
AND ssc.code = ses.SCHD_STAT_CD_CODE_K
AND seu.code = se.SCHD_EVNT_URL_CODE_K
AND se.id = ses.SCHD_EVNT_ID_K
AND se.id = ca.SCHD_EVNT_ID_K
AND ses.create_ts = (select max(create_ts)
FROM SCHD_evnt_stat ses1
WHERE ses1.SCHD_EVNT_ID_K = ses.SCHD_EVNT_ID_K)
AND
(sea.ATTENDEE_TYP(+) = 'WORKER' AND se.id = sea.SCHD_EVNT_ID_K(+)) --clause of the 1st query
OR
(sea.ATTENDEE_TYP = 'ROLE' AND se.id = sea.SCHD_EVNT_ID_K) --clause of the 2nd query
OR
(sea.ATTENDEE_TYP = 'ROLE' AND se.id = sea.SCHD_EVNT_ID_K AND au1.APP_ROLE_NAM_DESKTOP_K = sea.ATTENDEE_ID_K) --clause of the 3rd query
);
Similar Messages
-
How can i make this query run for a form
This query works fine for a sql report
SELECT *
FROM STUDENTS
WHERE given_name||' '||family_name = :P101_USERNAME
AND password = :P101_PASSWORD;
But i want it to do the same thing for a form but i dont have the option like i do for the report where i can just apply the condition to the process.
Anyone any ideas how i could do this so that when i go to the form this information is already there based on the username and password from the previous page?Assuming that page 101 is your login form, just lookup the primary key of the student based on the values presented in the login page fields, then set and pass this value to the form page.
So you would create a process that runs near the very end of the the login processes on page 101, something like this:
declare
l_student_id students.student_id%TYPE;
begin
select student_id into l_student_id from students where given_name||' '||family_name = :P101_USERNAME and password = :P101_PASSWORD;
-- then set the value of your form page primary key field
:P1_STUDENT_ID := l_student_id;
end;I've done something similar and it works fine for me, although I haven't looked at it recently.
Earl -
How Can I make this query run faster
SQL> EXPLAIN PLAN FOR SELECT a.txid, a.methodid, a.serviceid, a.nodename, a.env, a.ts, a.te, a.resultcode, a.resultmessage FROM g2log.txmaster a,
2 g2log.txlookup b WHERE b.key = 'sbcgnfttxuniquedslamportid' AND b.value = 'MTC3LS733001-1-1-2-13' AND a.txid = b.txid ORDER BY ts desc;
Explained.
Elapsed: 00:00:00.01
SQL> @$ORACLE_HOME/rdbms/admin/utlxpls.sql
PLAN_TABLE_OUTPUT
Plan hash value: 3790334907
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 578 | 108K| 1267 (1)| 00:00:16 | | |
| 1 | PX COORDINATOR | | | | | | | |
| 2 | PX SEND QC (ORDER) | :TQ10001 | 578 | 108K| 1267 (1)| 00:00:16 | | |
| 3 | SORT ORDER BY | | 578 | 108K| 1267 (1)| 00:00:16 | | |
| 4 | PX RECEIVE | | | | | | | |
| 5 | PX SEND RANGE | :TQ10000 | | | | | | |
| 6 | NESTED LOOPS | | | | | | | |
| 7 | NESTED LOOPS | | 578 | 108K| 1266 (1)| 00:00:16 | | |
| 8 | PX PARTITION RANGE ALL | | 578 | 44506 | 109 (0)| 00:00:02 | 1 | 27 |
| 9 | TABLE ACCESS BY LOCAL INDEX ROWID| TXLOOKUP | 578 | 44506 | 109 (0)| 00:00:02 | 1 | 27 |
|* 10 | INDEX RANGE SCAN | TX_KEY_VAL | 578 | | 58 (0)| 00:00:01 | 1 | 27 |
|* 11 | INDEX UNIQUE SCAN | TXMASTER_TXID_PK | 1 | | 1 (0)| 00:00:01 | | |
| 12 | TABLE ACCESS BY GLOBAL INDEX ROWID | TXMASTER | 1 | 116 | 2 (0)| 00:00:01 | ROWID | ROWID |
Predicate Information (identified by operation id):
10 - access("B"."KEY"='sbcgnfttxuniquedslamportid' AND "B"."VALUE"='MTC3LS733001-1-1-2-13')
11 - access("A"."TXID"="B"."TXID")
25 rows selected.
I have gathered stats on the two tables as well
SQL> select count(*) from g2log.txmaster;
COUNT(*)
88812
SQL> select count(*) from g2log.txlookup;
COUNT(*)
228883I bellieve that it is disabled as well:
SQL> show parameter parallel
NAME TYPE VALUE
fast_start_parallel_rollback string LOW
parallel_adaptive_multi_user boolean TRUE
parallel_automatic_tuning boolean FALSE
parallel_degree_limit string CPU
parallel_degree_policy string MANUAL
parallel_execution_message_size integer 16384
parallel_force_local boolean FALSE
parallel_instance_group string
parallel_io_cap_enabled boolean FALSE
parallel_max_servers integer 985
parallel_min_percent integer 0
parallel_min_servers integer 0
parallel_min_time_threshold string AUTO
parallel_server boolean TRUE
parallel_server_instances integer 2
parallel_servers_target integer 1024
parallel_threads_per_cpu integer 2
recovery_parallelism integer 0 -
How can I make this complex query?
I donât know how can I do this complex query...
I have the tables Customers, Vehicles and Models. A customer can have 0-N Vehicles and a vehicle have 1 Model.
Customers: ID_Customer (PK), Name, LastName...
Vehicles: ID_Vehicle (PK), ID_Customer, ID_Model, date_sale
Models: ID_Modelo (PK), Model_Name
Then I need to know the buy average time (date_sale) between 2 models (ID_Model)
For example I have these Vehicles:
ID_Vehicle (PK)...ID_Customer...ID_Model....date_sale
1................................123....................1.............21/05/2000
2................................459....................3............ 16/08/2000
3................................123....................2............ 28/06/2001
4................................516....................1............ 09/09/2001
5................................459....................4............ 18/10/2002
6................................516....................2............ 20/12/2002
If I want to know the buy average time (date_sale) between ID_Model 1 and ID_Model 2 it is. (403 + 467) / 2 = 435 days !!!
* Customer 123 (model 1 to 2): 25/06/2001 â 21/05/2000 ==> 403 days
* Customer 516 (model 1 to 2): 01/12/2002 â 01/05/2000 ==> 467 days.
I need to do the query for all the combination models. For example If I have the Models 1, 2 and 3 I need to obtain:
Source_Model.....Target_Model....Buy_Average_Time
1......................................1....................... xxx days
1......................................2....................... xxx days
1......................................3....................... xxx days
2......................................1....................... xxx days
2......................................2....................... xxx days
2......................................3....................... xxx days
3......................................1....................... xxx days
3......................................2....................... xxx days
3......................................3....................... xxx days
If it is necessary I could create a table with the fields Source_Model, Target_Model and Buy_Average_Time for accelerate the query time response.
But how can I do this query??????????
Thanks very much!!!Hi,
Thanks for your reply but It is not correct for me because the Customer could have several vehicles in her life.
If I make the query with my examples data it is OK
ID_Vehicle (PK)...ID_Customer...ID_Model....date_sale
1................................123....................1.............21/05/2000
2................................459....................3............ 16/08/2000
3................................123....................2............ 28/06/2001
4................................516....................1............ 09/09/2001
5................................459....................4............ 18/10/2002
6................................516....................2............ 20/12/2002
select v1.id_model as source_model,
v2.id_model as target_model,
avg (v2.date_sale - v1.date_sale) || ' days' as buy_average_time
from vehicles v1,
vehicles v2
where v1.id_customer = v2.id_customer
and v2.date_sale > v1.date_sale
group by v1.id_model, v2.id_model;
I received:
SOURCE_MODEL TARGET_MODEL BUY_AVERAGE_TIME
..............1................................2.....................................435 days
..............3................................4.....................................793 days
But If I insert a new vehicle:
ID_Vehicle (PK)...ID_Customer...ID_Model....date_sale
7................................516....................3............ 16/08/2003
And I execute the query now I receive:
SOURCE_MODEL TARGET_MODEL BUY_AVERAGE_TIME
..............1................................2...........................435 days
..............1................................3...........................706 days
..............2................................3...........................239 days
..............3................................4...........................793 days
It is NO correct because I donât have the 1 (Source_model) to 3 (Target_model) combination in the Vehicles data!!! (I have 1 to 2 and 2 to 3 but NO 1 to 3!!!!).
Then the query is not OK for me!
Besides If I modify the Vehicle 7 data and put ID_Model = 2:
ID_Vehicle (PK)...ID_Customer...ID_Model....date_sale
7................................516....................2............ 16/08/2003
I received:
SOURCE_MODEL TARGET_MODEL BUY_AVERAGE_TIME
..............1................................2...........................525,33 days
..............2................................2...........................239 days
..............3................................4...........................793 days
It is NO correct because the BUY_AVERAGE_TIME for 1 to 2 combination is 435 days (the same of the original query) because I aggregate only the combination 2 to 2 with the ID_VEHICLE 7
Below I attach the examples scripts.
Could you help me with this query, please?
Thanks very much!
CREATE TABLE VEHICLES
ID_VEHICLE NUMBER(9),
ID_CUSTOMER NUMBER(9),
ID_MODEL NUMBER(9),
DATE_SALE DATE
TABLESPACE USERS
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
LOGGING
NOCACHE
NOPARALLEL;
INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
1, 123, 1, TO_Date( '05/21/2000 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
2, 459, 3, TO_Date( '08/16/2000 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
3, 123, 2, TO_Date( '06/28/2001 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
4, 516, 1, TO_Date( '09/09/2001 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
5, 459, 4, TO_Date( '10/18/2002 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
6, 516, 2, TO_Date( '12/20/2002 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
7, 516, 2, TO_Date( '08/16/2003 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
COMMIT;
CREATE TABLE MODELS
ID_MODELO NUMBER(9),
MODEL_NAME VARCHAR2(25 BYTE)
TABLESPACE USERS
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
LOGGING
NOCACHE
NOPARALLEL;
INSERT INTO MODELS ( ID_MODELO, MODEL_NAME ) VALUES (
1, 'MODEL 1');
INSERT INTO MODELS ( ID_MODELO, MODEL_NAME ) VALUES (
2, 'MODEL 2');
INSERT INTO MODELS ( ID_MODELO, MODEL_NAME ) VALUES (
3, 'MODEL 3');
INSERT INTO MODELS ( ID_MODELO, MODEL_NAME ) VALUES (
4, 'MODEL 4');
COMMIT;
CREATE TABLE CUSTOMERS
ID_CUSTOMER NUMBER(9),
NAME VARCHAR2(25 BYTE),
LASTNAME VARCHAR2(25 BYTE)
TABLESPACE USERS
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
LOGGING
NOCACHE
NOPARALLEL;
INSERT INTO CUSTOMERS ( ID_CUSTOMER, NAME, LASTNAME ) VALUES (
123, 'Customer 123', 'A');
INSERT INTO CUSTOMERS ( ID_CUSTOMER, NAME, LASTNAME ) VALUES (
459, 'Customer 459', 'B');
INSERT INTO CUSTOMERS ( ID_CUSTOMER, NAME, LASTNAME ) VALUES (
516, 'Customer 516', 'C');
INSERT INTO CUSTOMERS ( ID_CUSTOMER, NAME, LASTNAME ) VALUES (
318, 'Customer 318', 'D');
COMMIT; -
I seem to have less space for my download.How can I make this download happen?????? Will I have to uninstall my old Adobe Photoshop(which has long since worked) in order for this to be installed??
What exactly are you trying to download on what system? Feel free to download to external drives to bypass the immediate bottleneck, but that may not resolve your issue once you install....
Mylenium -
How can I make a query by date with several TDMS files?
Hi,
I have a project that can write and read TDMS files everyday (a file for each day with date and time). There, I can import those files to excel (I choose a file and load it). But, I have a question: How can I make a query by date with those TDMS files? I'd like make a time stamp for start date and stop date, where I could compare the TDMS file dates and sum the values that are in the channels where these files are similar. For example, I save a file with "02/01/2013" name, in other day "03/01/2013", in other day "04/01/2013"... so, i'd like put in time stamp for start date "02/01/2013" file and to stop date "04/01/2013" file, than, sum all values that range with my TDMS files existing. How can I make that?
Thanks all,
ValHello Val_Auto.
You're Brazilian, no? Me too. = ^ - ^ =
I converted VI to version of your LabVIEW (8.5). Is attached in this reply.
This VI search all your TDMS in a range of dates and join them in a single TDMS. I hope this is what you wanted.
Query TDMS is the main VI. The TDMS VI Search changes the date format that out from calendar control (which is DD / MM / YYYY) to DD-MM-YYYY. This is because you can't name files using "/". I chose "-" but, if necessary, you should change to keep the same format of your TDMS files.
If you have any doubt as to its operation or how to make changes to adapt VI for your application, keep at your disposal.
Thank you for your contact; I hope have helped you and succeed in your application.
Wesley Rocha
Application Engineer
National Instruments Brazil
Visite a nossa comunidade em PORTUGUÊS!!!
Attachments:
Query TDMS.vi 62 KB
tdms search.vi 24 KB -
How can i improve this query.
Hi guys i am beginner , just wanted to know some info , how can i improve this query ..
select *
from tableA A, viewB B,
where A.key = B.key
and a.criteria1 = '111'
and a.criteria2 = some_funtion(a.key)
one more thing should function should be on left side of equal sign.
will a join make it better or something else is needed more than that .952936 wrote:
Hi guys i am beginner , just wanted to know some info , how can i improve this query ..
select *
from tableA A, viewB B,
where A.key = B.key
and a.criteria1 = '111'
and a.criteria2 = some_funtion(a.key)
one more thing should function should be on left side of equal sign.
will a join make it better or something else is needed more than that .If you are a beginner try to learn the ANSI Syntax. This will help you a lot to write better queries.
Your select would look like this in ANSI.
select *
from tableA A
JOIN viewB B ON A.key = B.key
WHERE a.criteria1 = '111'
and a.criteria2 = some_function(a.key);The good thing here is that this separates the typical joining part of the select from the typical filter criteria.
The other syntax very often let you forget one join. Just because there are so many tables and so many filters, that you just don't notice correctly anymore what was join and what not.
If you notice that the number of column is not what you expect, you can easiely modify the query and compare the results.
example A
Remove View B from the query (temporarily comment it out).
select *
from tableA A
--JOIN viewB B ON A.key = B.key
WHERE a.criteria1 = '111'
and a.criteria2 = some_funtion(a.key)
example B
You notice, that values from A are missing. Maybe because there is no matching key in ViewB? Then change the join to an outer join.
select *
from tableA A
LEFT OUTER JOIN viewB B ON A.key = B.key
WHERE a.criteria1 = '111'
and a.criteria2 = some_funtion(a.key)(The outer keyword is optional, left join would be enough). -
How can I make this join in ADF and make CRUD operation in this
How to make this relation in ADF
I have table employees and this is my master table
Table Name: Employees
Columns:
Employee_id(PK)
Employee_name
Employee_Salary
I have a child table that is called related employee that contains employees related to this employee
Table_name: Related_Employee
Columns:
Related_Employee_Table_Id(PK)
Employee_id(FK)
Related_Employee_Id
When I open employee id = 100 for example and add related employee id = 10
this is added with no problem but the requirement is that when I open employee 10 I find employee id 100 as related employee
How can I make this scenario.The best way to understand this is to look at an example. If you are using an oracle database such as XE for you have a schema called hr. This shema has a number of tables two of which are departments and employees. a department has multiple employees correct. So in your example a employee may be related to x # of other employees perhaps. A very similar scenario as that in the hr Schema. If you don't have an Oracle XE database, download one from here -> http://www.oracle.com/technetwork/database/express-edition/downloads/index.html
Create Business Components off of the Departments and Employees schema and you'll see that due to the db design, you get what you're talking about for free (i.e. the join). Thus, you have the master-detail relationship you're looking for. For a quick tip, here is the relationship between departments and employees in the hr schema via a create script that you can exam with data inserts included:
SET SQLBLANKLINES ON
CREATE TABLE DEPARTMENTS
DEPARTMENT_ID NUMBER(4, 0) NOT NULL
, DEPARTMENT_NAME VARCHAR2(30 BYTE) NOT NULL
, MANAGER_ID NUMBER(6, 0)
, LOCATION_ID NUMBER(4, 0)
, CONSTRAINT DEPT_ID_PK PRIMARY KEY
DEPARTMENT_ID
USING INDEX
CREATE UNIQUE INDEX DEPT_ID_PK ON DEPARTMENTS (DEPARTMENT_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
ENABLE
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 1
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE TABLE EMPLOYEES
EMPLOYEE_ID NUMBER(6, 0) NOT NULL
, FIRST_NAME VARCHAR2(20 BYTE)
, LAST_NAME VARCHAR2(25 BYTE) NOT NULL
, EMAIL VARCHAR2(25 BYTE) NOT NULL
, PHONE_NUMBER VARCHAR2(20 BYTE)
, HIRE_DATE DATE NOT NULL
, JOB_ID VARCHAR2(10 BYTE) NOT NULL
, SALARY NUMBER(8, 2)
, COMMISSION_PCT NUMBER(2, 2)
, MANAGER_ID NUMBER(6, 0)
, DEPARTMENT_ID NUMBER(4, 0)
, CONSTRAINT EMP_EMP_ID_PK PRIMARY KEY
EMPLOYEE_ID
USING INDEX
CREATE UNIQUE INDEX EMP_EMP_ID_PK ON EMPLOYEES (EMPLOYEE_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
ENABLE
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 1
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX DEPT_LOCATION_IX ON DEPARTMENTS (LOCATION_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX EMP_DEPARTMENT_IX ON EMPLOYEES (DEPARTMENT_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX EMP_JOB_IX ON EMPLOYEES (JOB_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX EMP_MANAGER_IX ON EMPLOYEES (MANAGER_ID ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
CREATE INDEX EMP_NAME_IX ON EMPLOYEES (LAST_NAME ASC, FIRST_NAME ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_EMAIL_UK UNIQUE
EMAIL
USING INDEX
CREATE UNIQUE INDEX EMP_EMAIL_UK ON EMPLOYEES (EMAIL ASC)
LOGGING
TABLESPACE "USERS"
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
ENABLE;
ALTER TABLE DEPARTMENTS
ADD CONSTRAINT DEPT_LOC_FK FOREIGN KEY
LOCATION_ID
REFERENCES LOCATIONS
LOCATION_ID
ENABLE;
ALTER TABLE DEPARTMENTS
ADD CONSTRAINT DEPT_MGR_FK FOREIGN KEY
MANAGER_ID
REFERENCES EMPLOYEES
EMPLOYEE_ID
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_DEPT_FK FOREIGN KEY
DEPARTMENT_ID
REFERENCES DEPARTMENTS
DEPARTMENT_ID
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_JOB_FK FOREIGN KEY
JOB_ID
REFERENCES JOBS
JOB_ID
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_MANAGER_FK FOREIGN KEY
MANAGER_ID
REFERENCES EMPLOYEES
EMPLOYEE_ID
ENABLE;
ALTER TABLE DEPARTMENTS
ADD CONSTRAINT DEPT_NAME_NN CHECK
(DEPARTMENT_NAME IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_EMAIL_NN CHECK
(EMAIL IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_HIRE_DATE_NN CHECK
(HIRE_DATE IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_JOB_NN CHECK
(JOB_ID IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_LAST_NAME_NN CHECK
(LAST_NAME IS NOT NULL)
ENABLE;
ALTER TABLE EMPLOYEES
ADD CONSTRAINT EMP_SALARY_MIN CHECK
(SALARY > 0)
ENABLE;
COMMENT ON TABLE DEPARTMENTS IS 'Departments table that shows details of departments where employees
work. Contains 27 rows; references with locations, employees, and job_history tables.';
COMMENT ON TABLE EMPLOYEES IS 'employees table. Contains 107 rows. References with departments,
jobs, job_history tables. Contains a self reference.';
COMMENT ON COLUMN DEPARTMENTS.DEPARTMENT_ID IS 'Primary key column of departments table.';
COMMENT ON COLUMN DEPARTMENTS.DEPARTMENT_NAME IS 'A not null column that shows name of a department. Administration,
Marketing, Purchasing, Human Resources, Shipping, IT, Executive, Public
Relations, Sales, Finance, and Accounting. ';
COMMENT ON COLUMN DEPARTMENTS.MANAGER_ID IS 'Manager_id of a department. Foreign key to employee_id column of employees table. The manager_id column of the employee table references this column.';
COMMENT ON COLUMN DEPARTMENTS.LOCATION_ID IS 'Location id where a department is located. Foreign key to location_id column of locations table.';
COMMENT ON COLUMN EMPLOYEES.EMPLOYEE_ID IS 'Primary key of employees table.';
COMMENT ON COLUMN EMPLOYEES.FIRST_NAME IS 'First name of the employee. A not null column.';
COMMENT ON COLUMN EMPLOYEES.LAST_NAME IS 'Last name of the employee. A not null column.';
COMMENT ON COLUMN EMPLOYEES.EMAIL IS 'Email id of the employee';
COMMENT ON COLUMN EMPLOYEES.PHONE_NUMBER IS 'Phone number of the employee; includes country code and area code';
COMMENT ON COLUMN EMPLOYEES.HIRE_DATE IS 'Date when the employee started on this job. A not null column.';
COMMENT ON COLUMN EMPLOYEES.JOB_ID IS 'Current job of the employee; foreign key to job_id column of the
jobs table. A not null column.';
COMMENT ON COLUMN EMPLOYEES.SALARY IS 'Monthly salary of the employee. Must be greater
than zero (enforced by constraint emp_salary_min)';
COMMENT ON COLUMN EMPLOYEES.COMMISSION_PCT IS 'Commission percentage of the employee; Only employees in sales
department elgible for commission percentage';
COMMENT ON COLUMN EMPLOYEES.MANAGER_ID IS 'Manager id of the employee; has same domain as manager_id in
departments table. Foreign key to employee_id column of employees table.
(useful for reflexive joins and CONNECT BY query)';
COMMENT ON COLUMN EMPLOYEES.DEPARTMENT_ID IS 'Department id where employee works; foreign key to department_id
column of the departments table'; -
Could you please help me make this query less complicated
could you please help me make this query less complicated
select t1.R_OBJECT_ID
from dm_relation_sp a, ddt_resolution_sp t1
where a.parent_id = '0900000283560456' -----------ID
and a.child_id = t1.R_OBJECT_ID
union all
select t3.R_OBJECT_ID
from ddt_resolution_sp t3
where t3.R_OBJECT_ID in (select t2.child_id
from dm_relation_sp t2
where t2.parent_id in (select a.child_id
from asud_fsk.dm_relation_sp a, asud_fsk.ddt_resolution_sp t1
where a.parent_id = '0900000283560456' -----------ID
and a.child_id = t1.R_OBJECT_ID))
union all
select t4.R_OBJECT_ID
from ddt_resolution_sp t4
where t4.R_OBJECT_ID in(
select t3.child_id from dm_relation_sp t3
where t3.parent_id in (
select t2.child_id
from asud_fsk.dm_relation_sp t2
where t2.parent_id in (select a.child_id
from asud_fsk.dm_relation_sp a, asud_fsk.ddt_resolution_sp t1
where a.parent_id = '0900000283560456' -----------ID
and a.child_id = t1.R_OBJECT_ID))
and t3.relation_name = 'RESOLUTION_RELATION')
union all
select t5.R_OBJECT_ID
from ddt_resolution_sp t5
where t5.R_OBJECT_ID in
(select t4.child_id
from dm_relation_sp t4
where t4.parent_id in(
select t3.child_id from dm_relation_sp t3
where t3.parent_id in (
select t2.child_id
from asud_fsk.dm_relation_sp t2
where t2.parent_id in (select a.child_id
from asud_fsk.dm_relation_sp a, asud_fsk.ddt_resolution_sp t1
where a.parent_id = '0900000283560456' -----------ID
and a.child_id = t1.R_OBJECT_ID))
and t3.relation_name = 'RESOLUTION_RELATION')
and t4.relation_name = 'RESOLUTION_RELATION')
Edited by: user13025450 on 29.04.2010 16:23Hi,
Welcome to the forum! You'll find that there are many qualified people (such as Tubby) willing to help you. Will you do what you can to help them? In order to simplify the query you posted,someone will first have to understand what it does, what the tables that it uses are like, and what tools you have to work with (that is, what version of Oracle, and any other software you are using). To actually test their ideas, people will need versions of your tables.
Many people, if they spent enough time, might be able to figure out roughly what you are doing, make some tables themselves and test a solution. You can help with all of that. I assume you already know what the appliction is, and what this particular query is supposed to do: you don't have to figure out any of that, you just have to say it. You know what all your tables are, what the datatypes of all the columns are, and what kinds of data are in the tables: you don't have to guess at any of that.
Describe what you're doing. Think about it: how do we know that
SELECT NULL
FROM dual;doesn't do what you want?
Post CREATE TABLE and INSERT statements for a little sample data.
Post the results that this query is supposed to produce from those results. (Is it producing the right output now? Then it should be easy to post the correct results.)
Describe, as well as you can, how the present query is doing it.
Format your existing code, so it's easy to see what the different branches of the UNION are, and what the main clauses are in each one.
When posting formatted text (code or results) type these 6 characters
\(all small letters, inside curly brackets) before and after each formatted section, to keep this site from compressing the spaces.
Say what versions of Oracle (e.g. 10.2.0.3.0) and any other relevant software you are using.
I know it's a lot of work, but it really helps. You can do it as well (probably better) than anyone else, and if you're unwilling to do it, why should anyone else be willing? -
I have an ipad mini. From one moment to another a document that was created and used on pages app ( on the ipad mini) does not want to open ( When pressed it states " document cant be opened). How can I make this document open again?
I have tried back ups and restoring, resetting, and even updating the pages app. And nothing has worked.I have an ipad mini. From one moment to another a document that was created and used on pages app ( on the ipad mini) does not want to open ( When pressed it states " document cant be opened). How can I make this document open again?
I have tried back ups and restoring, resetting, and even updating the pages app. And nothing has worked. -
I'm new to mac. Just started out. Have OS 10.8.3. I have an HP 1315 printer. It prints and copies, wont scan. I see old threads on this, nothing recent. ?can i make this work, or do i need a new printer??
Hi Newbie111
I see that you are unable to scan with the Photosmart 1315.
What driver are you using?
The driver listed in the url below is a basic print driver that will allow you to print only.
http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?softwareitem=ps242muc&c c=us&dlc=en&lc=en&os=1006&product=61956&sw_lang=
You can try using the apple drivers in the url below.
http://support.apple.com/kb/DL907
If you have any further issues please let me know. -
I keep Mail open on my MacBook Pro and prior to Mavericks items would open on my 27" secondary display. How can I make this happen in Mavericks?
In System Preferences > Mission Control, uncheck mark Displays have seperate windows. This should bring you back to the secondary display you had before the upgrade. You may have to open Mail, the first time and place it on your secondary display. You also won't have the advantages of the dock and menus on the secondary display.
I keep my own secondary display with these settings because I need the ability to expand a window across both displays. -
I have a iPad and I connect it to my tv through hdmi but would like the sound to come out through the headphone socket, can I make this happen.
Go to System Preferences>Sound>Output and make sure that you selected the right output. I think if yo use HDMI you might not be abe to select another output.
-
When filling out a form, some fields copy to others when I tab to the next. How can I make this stop?
You can't using Adobe Reader. It looks like whomever created the form used the same identifiers (names) for various fields. Each field with the same name will populate with the information used in another field of the same name. This is intentional.
Normally when I see this, it tells me that someone created an initial field then copy/pasted it to make additional fields but forgot to change the names. -
Just restored my iPhone 5 from iCloud. My wife and I have always shared one iCloud ID. But since my restore, when a call comes in, it rings on both my phone and hers. How can I make this stop? We had it all set up fine before the restore, and there was a trick to it in the settings. I've noticed that since my restore, her phone has picked up what looks like the symbol of a phone in the upper right corner of the display, right next to the Bluetooth symbol.
Hi Big Slick,
Welcome to the Apple Support Community!
It sounds like your iPhones may be using a new feature in iOS 8 called Continuity. The following article and information explains how to set up this feature for phone calls. You can review the information on the setup to reverse this effect. My suggestion would be to turn off FaceTime on one of the devices.
Connect your iPhone, iPad, iPod touch, and Mac using Continuity
Phone calls
With Continuity, you can make and receive cellular phone calls from your iPad, iPod touch, or Mac when your iPhone is on the same Wi-Fi network.
To make and receive phone calls, here's what you need:
Sign in to the same iCloud account on all your devices, including your Mac.
Your iPhone and your iPad or iPod touch need to use iOS 8 or later. Your Mac needs to use OS X Yosemite.
All devices must be on the same Wi-Fi network.
All devices must be signed in to FaceTime using the same iCloud account. This means any device that shares your Apple ID will get your phone calls. Look below for instructions on how to turn off iPhone cellular calls.
Wi-Fi Calling needs to be off. Go to Settings > Phone. If you see Wi-Fi Calling, turn it off.
Cheers,
Joe
Maybe you are looking for
-
Question slides auto advancing prior to an answer being selected
Hi- I have searched the postings and cannot find anything similar to what I am experiencing. This only happens once the user has gone through the quiz once and has failed. The passing grade is a 100%, so the chances of someone needing to re-take the
-
Address Book: Deleting 'Department' field - TOTAL NEWBIE
Hi... I amended a card to include the Department Field via the 'add field' function. Now I can't delete it as I want to use a different field instead. Can someone please help? Tks...
-
Replaced Internal HD - Can TM Backup Continue to BU New HD?
Replaced 500 GB internal boot HD with larger 750 GB internal -- cloned 500 onto 750, and 750 now resides internally as primary boot drive (SL 10.6). Was backing up via TM to USB 1 TB volume. Since the data on my new 750 GB drive is identical to old 5
-
My iTunes hasn't been updated in a few years
I've had to uninstall iTunes and just recently reinstalled it. I receive an update notification after the other & the upgrade list continues for days. Is it possible to do an overall update without doing them single? & I'm not sure what software I ha
-
Please help. AIW 9800Pro artifcacts & BIOS problem?
I am in dire need of help. I have been trying to get my AIW 9800 Pro video card running on the MSI board for over a week. I have got Windows Pro up and running with Nvidia AGP video card, however whenever I use my ATI All-In-Wonder 9800 Pro 128mb