SQL Query Group By Issues - Urgent
I currently have an issue writing a pl\sql report, I can get part of the way to the results I want but the group by clause is causing problems, because I have to add more columns to the group by, dispersing the figures further, I have tried it with coalesce for each of the task types but I still get the same results, I am getting close to the results I need but not quite there yet. I would really appreciate it if someone could take at look at this for me as it is an urgent requirement.
The report is based on the tables similar to the following:
TASKS, ORGANISATIONS, POSITIONS
A position is a member of an organisation.
A task has a position assigned to it.
The SQL for the tables and to insert the data that would produce the report is detailed below:
CREATE TABLE TASKS
( TASK_ID NUMBER NOT NULL ENABLE,
TASK_TYPE VARCHAR2 (15 BYTE) NOT NULL ENABLE,
STATUS VARCHAR2 (15 BYTE) NOT NULL ENABLE,
POS_ID NUMBER NOT NULL ENABLE,
CONSTRAINT TASKS_PK PRIMARY KEY (TASK_ID));
CREATE TABLE ORGANISATIONS
( ORG_ID NUMBER NOT NULL ENABLE,
ORG_NAME VARCHAR2 (15 BYTE) NOT NULL ENABLE,
CONSTRAINT ORGANISATIONS_PK PRIMARY KEY (ORG_ID));
CREATE TABLE POSITIONS
( POS_ID NUMBER NOT NULL ENABLE,
POS_NAME VARCHAR2 (25 BYTE) NOT NULL ENABLE,
ORG_ID NUMBER NOT NULL ENABLE,
CONSTRAINT POSITIONS_PK PRIMARY KEY (POS_ID));
INSERT INTO ORGANISATIONS (ORG_ID, ORG_NAME) VALUES (1,'ABC');
INSERT INTO ORGANISATIONS (ORG_ID, ORG_NAME) VALUES (2,'DEF');
INSERT INTO ORGANISATIONS (ORG_ID, ORG_NAME) VALUES (3,'EFG');
INSERT INTO POSITIONS (POS_ID, POS_NAME, ORG_ID) VALUES (1,'ABC-1', 1);
INSERT INTO POSITIONS (POS_ID, POS_NAME, ORG_ID) VALUES (3,'ABC-2', 1);
INSERT INTO POSITIONS (POS_ID, POS_NAME, ORG_ID) VALUES (2,'ABC-3', 1);
INSERT INTO POSITIONS (POS_ID, POS_NAME, ORG_ID) VALUES (5,'DEF-2', 2);
INSERT INTO POSITIONS (POS_ID, POS_NAME, ORG_ID) VALUES (4,'DEF-1', 2);
INSERT INTO POSITIONS (POS_ID, POS_NAME, ORG_ID) VALUES (7,'EFG-1', 3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (12,'TASK_TYPE_3','LIVE',3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (11,'TASK_TYPE_2','LIVE',3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (10,'TASK_TYPE_2','LIVE',2);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (9,'TASK_TYPE_2','LIVE',2);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (8,'TASK_TYPE_1','LIVE',3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (7,'TASK_TYPE_1','LIVE',3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (6,'TASK_TYPE_1','LIVE',3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (5,'TASK_TYPE_1','LIVE',3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (4,'TASK_TYPE_1','LIVE',2);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (3,'TASK_TYPE_3','LIVE',1);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (2,'TASK_TYPE_1','LIVE',1);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (1,'TASK_TYPE_1','LIVE',1);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (13,'TASK_TYPE_3','LIVE',3);
The report should detail the following information based on the information in the tables:
1st Column
Organisation
ABC
DEF
EFG
2nd Column
No. of Positions in Organsiation
3
2
1
With total of the number of people in all of the organisation 6
3rd Column
Number of tasks assigned to the organisation of task type1
2
1
4
4th Column
Number of tasks assigned to the organisation of task type 2
0
2
1
5th Column
Number of tasks assigned to the organisation of task type 3
1
0
2
Total no of tasks assigned to the Organisation
3
3
7
Message was edited by:
Suzy_r_82
Message was edited by:
Suzy_r_82
Hi,
Apologies, my insert statements where incorrect, if you try the data below instead it should give you output I was expecting
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (1,'TASK_TYPE_1', 'LIVE',1);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (2,'TASK_TYPE_1', 'LIVE',2);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (3,'TASK_TYPE_1', 'LIVE',5);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (4,'TASK_TYPE_1', 'LIVE',7);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (5,'TASK_TYPE_1', 'LIVE',7);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (6,'TASK_TYPE_1', 'LIVE',7);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (7,'TASK_TYPE_1', 'LIVE',7);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (8,'TASK_TYPE_2', 'LIVE',4);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (9,'TASK_TYPE_2', 'LIVE',5);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (10,'TASK_TYPE_3', 'LIVE',1);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (11,'TASK_TYPE_3', 'LIVE',7);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (12,'TASK_TYPE_2', 'LIVE',7);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (13,'TASK_TYPE_3', 'LIVE',7);
The results I would like are
ORG No. of Pos No of Task No of Task No of Task Total no
In Org Type1 for Type2 for Type3 for of Tasks
Org Org Org for Org
ABC 3 2 0 1 3
DEF 2 1 2 0 3
EFG 1 4 1 2 7
Total 6The results I get are multiple lines for each organisation, I would like to rollup these lines so I can have one line per organisation.
Hope this helps a bit more, I appreciate the help, let me know if you need more information
Thanks
Suzy
Similar Messages
-
SQL query, IF ELSE issue - Help.
I am trying to migrate data from one table to another, however I am having problems trying to figure out a small issue in my Query.
I'm using Oracle 11g, SQL Developer 3.0
here is my old table
CREATE TABLE PROD.RELATED_OFFENDERS
CREATED_DATETIME DATE ,
LAST_UPD_DATETIME DATE ,
LAST_UPD_ID VARCHAR2 (30 BYTE) ,
CREATOR_ID VARCHAR2 (30 BYTE) ,
USSC_ID NUMBER (10) ,
REL_ORG_ID NUMBER (10) NOT NULL ,
REL_ORG_NAME VARCHAR2 (100 BYTE) ,
REL_IND_NAMES VARCHAR2 (100 BYTE) ,
REL_DOCKET_NUM VARCHAR2 (7 BYTE) ,
REL_LEVEL_AUTH NUMBER (2) ,
REL_LEVEL_AUTH_TEXT VARCHAR2 (240 BYTE) ,
SENT_TYPE_CODE NUMBER (2) ,
INDICATOR VARCHAR2 (1 BYTE)
ALTER TABLE PROD.RELATED_OFFENDERS
ADD CONSTRAINT RO_PK PRIMARY KEY ( REL_ORG_ID ) ;New table
CREATE TABLE USSC_CASES.CORP_RELATED_OFFENDERS
REL_ORG_ID NUMBER (10) NOT NULL ,
SENT_ID NUMBER (12) NOT NULL ,
DEF_TYPE_CODE NUMBER (1) ,
DEF_TYPE_NAME VARCHAR2 (100 BYTE) ,
REL_DOCKET_NUM VARCHAR2 (7 BYTE) ,
REL_LVL_AUTH NUMBER (1) ,
REL_LVL_AUTH_TEXT VARCHAR2 (240 BYTE)
ALTER TABLE USSC_CASES.CORP_RELATED_OFFENDERS
ADD CONSTRAINT CORP_REL_OFF_PK PRIMARY KEY ( REL_ORG_ID ) ;In the old table you will notice i have the following attributes:
REL_ORG_NAME VARCHAR2 (100 BYTE) ,
REL_IND_NAMES VARCHAR2 (100 BYTE) ,
In my new table I have both columns as one called DEF_TYPE_NAME VARCHAR2 (100 BYTE).
what I'm trying to do is use the INDICATOR column VALUE (old table) for each row and say the following in SQL code:
(if INDICATOR = 'I' then DEF_TYPE_NAME = the value of REL IND_NAMES
else if INDICATOR = 'O' then DEF_TYPE_NAME = the value of REL_ORG_NAME) AS DEF_TYPE_NAME
here is my query
INSERT INTO USSC_CASES.CORP_RELATED_OFFENDERS
SELECT
RO.REL_ORG_ID AS REL_ORG_ID,
S.SENT_ID AS SENT_ID,
DECODE(RO.INDICATOR, UPPER(TRIM('I')), 1, 2) AS DEF_TYPE_CODE,
AS DEF_TYPE_NAME, -- here is where I'm having issues.
RO.REL_DOCKET_NUM AS REL_DOCKET_NUM,
RO.REL_LVL_AUTH AS REL_LVL_AUTH,
RO.REL_LVL_AUTH_TEXT AS REL_LVL_AUTH_TEXT
FROM PROD.RELATED_OFFENDERS RO,
PROD.SENTENCES S
WHERE RO.USSC_ID = S.CORPSENT_USSC_ID
AND RO.SENT_TYPE_CODE = S.SENT_TYPE_CODE
AND RO.SENT_TYPE_CODE = 1
ORDER BY REL_ORG_ID;Thanks in advance for your help.INSERT INTO USSC_CASES.CORP_RELATED_OFFENDERS
SELECT RO.REL_ORG_ID AS REL_ORG_ID,
S.SENT_ID AS SENT_ID,
CASE RO.INDICATOR
WHEN 'I' THEN REL_IND_NAMES
WHEN 'O' THEN REL_ORG_NAME
END AS DEF_TYPE_NAME,
RO.REL_DOCKET_NUM AS REL_DOCKET_NUM,
RO.REL_LVL_AUTH AS REL_LVL_AUTH,
RO.REL_LVL_AUTH_TEXT AS REL_LVL_AUTH_TEXT
FROM PROD.RELATED_OFFENDERS RO,
PROD.SENTENCES S
WHERE RO.USSC_ID = S.CORPSENT_USSC_ID
AND RO.SENT_TYPE_CODE = S.SENT_TYPE_CODE
AND RO.SENT_TYPE_CODE = 1
ORDER BY REL_ORG_ID;SY. -
SQL query slow when issued by app, fast when issued mnaually
Hi there,
I have a more general question about a specific Oracle behaviour.
I update a feature from within an application. The application doesn't respond and I finally have to terminate it. I checked Oracle whether a query is running long using the following statement:
select s.username,s.sid,s.serial#,s.last_call_et/60 mins_running,q.sql_text from v$session s
join v$sqltext_with_newlines q
on s.sql_address = q.address
where status='ACTIVE'
and type <>'BACKGROUND'
and last_call_et> 60
order by sid,serial#,q.piece
The result of the above query is:
WITH CONNECTION AS ( SELECT * FROM WW_CONN C WHERE (C.FID_FROM I
N (SELECT FID FROM WW_LINE WHERE FID_ATTR=:B1 ) AND C.F_CLASS_ID
FROM =22) OR (C.FIDTO IN (SELECT FID FROM WW_LINE WHERE FID_AT
TR=:B1 ) AND C.F_CLASS_ID_TO =22) ) SELECT MIN(P.FID_ATTR) AS FI
D_FROM FROM CONNECTION C, WW_POINT P WHERE (P.FID = C.FID_FROM A
ND C.F_CLASS_ID_FROM = 32 AND C.FLOW = 1) OR (P.FID = C.FID_TO A
ND C.F_CLASS_ID_TO = 32 AND C.FLOW = 2)
I have a different tool which shows me the binding parameter values. So I know that the value for :B1 is 5011 - the id of the feature being updated. This query runs for 20 mins and longer before it eventually stops. The update process involves multiple sql statements - so this one is not doing the update but is part of the process.
Here is the bit I do not understand: when I run the query in SQL Developer with value 5011 for :B1 it takes 0.5 secs to return a result.
Why is it, that the sql statement takes so long when issued by the application but takes less than a second when I run it manually?
I sent a dump of the data to the application vendor who is not able to reproduce the issue in their environment. Could someone explain to me what happens here or give me some keywords for further research?
We are using 11gR2, 64bit.
Many thanks,
RobHi Rob,
at least you should see some differences in the statistics for the different child cursor (the one for the execution in the application should show at least a higher value for ELAPSED_TIME). I would use something like the following query to check the information for the child cursors:
select sql_id
, PLAN_HASH_VALUE
, CHILD_NUMBER
, EXECUTIONS
, ELAPSED_TIME
, USER_IO_WAIT_TIME
, CONCURRENCY_WAIT_TIME
, DISK_READS
, BUFFER_GETS
, ROWS_PROCESSED
from v$sql
where sql_id = your_sql_idRegards
Martin -
SQL Query Having performance issues
I need help on rewriting this query, I am having performance issues with the way it is now. I create a temporary table and query against it. Any help will be appreciated. Thanks, Antonio
Here it is:
create global temporary table pr_php_elig_tmp
on commit preserve rows as
SELECT UNIQUE A.SAK_PROV, A.CDE_SERVICE_LOC, a.sak_short
FROM T_PR_PHP_ELIG A,
T_PR_TYPE C
WHERE C.SAK_PROV = A.SAK_PROV
AND C.CDE_SERVICE_LOC = A.CDE_SERVICE_LOC
AND C.CDE_PROV_TYPE not in ('01', '03', '08', '24', '27', '31')
AND A.SAK_PROV_PGM not in (11, 13)
AND A.DTE_END >= :il_current_date
AND A.DTE_EFFECTIVE <= :il_prev_18_months
AND NOT EXISTS (
SELECT 'X'
FROM T_PR_GRP_MBR T
WHERE T.SAK_PROV = A.SAK_PROV
AND T.CDE_SVC_LOC_MBR = A.CDE_SERVICE_LOC)
AND NOT EXISTS (
select a.sak_prov, a.cde_service_loc
from t_pmp_svc_loc d
where a.sak_prov = d.sak_prov
and a.cde_service_loc = d.cde_service_loc
and d.dte_end >= :il_current_date)
ORDER BY A.SAK_PROV, A.CDE_SERVICE_LOC;
select * from pr_php_elig_tmp
minus
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_dntl_dtl temp01
WHERE temp01.sak_prov_perf = a.sak_prov
and temp01.cde_svc_loc_perf = a.cde_service_loc
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp01.DTE_FIRST_SVC) >= :il_prev_18_months
OR NVL(MAX(temp01.DTE_FIRST_SVC),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_dntl_hdr temp02
WHERE ( (temp02.prov_billing = a.sak_prov
and temp02.cde_service_loc = a.cde_service_loc)
OR (temp02.sak_prov_perf = a.sak_prov
and temp02.cde_perf_svc_loc = a.cde_service_loc)
OR (temp02.sak_prov_referring = a.sak_prov
and temp02.cde_svc_loc_ref_1 = a.cde_service_loc)
OR (temp02.sak_prov_referring_2 = a.sak_prov
and temp02.cde_svc_loc_ref_2 = a.cde_service_loc)
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp02.DTE_FINAL) >= :il_prev_18_months
OR NVL(MAX(temp02.DTE_FINAL),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_phrm_hdr temp03
WHERE ( (temp03.prov_billing = a.sak_prov and
temp03.cde_service_loc = a.cde_service_loc)
OR (temp03.sak_prov_rendering = a.sak_prov and
temp03.cde_svc_loc_rend = a.cde_service_loc)
OR (temp03.sak_presc_prov = a.sak_prov and
temp03.cde_svc_loc_presc = a.cde_service_loc)
OR temp03.id_prov_prescrb = to_char(a.sak_prov) || a.cde_service_loc
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp03.DTE_FINAL) >= :il_prev_18_months
OR NVL(MAX(temp03.DTE_FINAL),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_phys_dtl temp04
WHERE ( (temp04.sak_prov_perf = a.sak_prov
and temp04.cde_svc_loc_rend = a.cde_service_loc)
OR (temp04.sak_prov_referring = a.sak_prov
and temp04.cde_svc_loc_ref_1 = a.cde_service_loc)
OR (temp04.sak_prov_referring_2 = a.sak_prov
and temp04.cde_svc_loc_ref_2 = a.cde_service_loc)
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp04.DTE_LAST_SVC) >= :il_prev_18_months
OR NVL(MAX(temp04.DTE_LAST_SVC),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_phys_hdr temp05
WHERE ( (temp05.prov_billing = a.sak_prov
and temp05.cde_service_loc = a.cde_service_loc)
OR (temp05.sak_prov_perf = a.sak_prov
and temp05.cde_perf_svc_loc = a.cde_service_loc)
OR (temp05.sak_prov_referring = a.sak_prov
and temp05.cde_svc_loc_ref_1 = a.cde_service_loc)
OR (temp05.sak_prov_referring_2 = a.sak_prov
and temp05.cde_svc_loc_ref_2 = a.cde_service_loc)
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp05.DTE_FINAL) >= :il_prev_18_months
OR NVL(MAX(temp05.DTE_FINAL),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_ub92_dtl temp06
WHERE ( (temp06.sak_pr_other = a.sak_prov
and temp06.cde_scv_loc_other = a.cde_service_loc)
OR (temp06.sak_pr_other_2 = a.sak_prov
and temp06.cde_svc_loc_other_2 = a.cde_service_loc)
OR (temp06.sak_pr_attend = a.sak_prov
and temp06.cde_svc_loc_attend = a.cde_service_loc)
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp06.DTE_LAST_SVC) >= :il_prev_18_months
OR NVL(MAX(temp06.DTE_LAST_SVC),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_deny_ub92_hdr temp07
WHERE ( (temp07.prov_billing = a.sak_prov
and temp07.cde_service_loc = a.cde_service_loc)
OR (temp07.sak_pr_facility = a.sak_prov
and temp07.cde_svc_loc_fa = a.cde_service_loc)
OR (temp07.sak_pr_other = a.sak_prov
and temp07.cde_svc_loc_other = a.cde_service_loc)
OR (temp07.sak_pr_other_2 = a.sak_prov
and temp07.cde_svc_loc_other_2 = a.cde_service_loc)
OR (temp07.sak_pr_attend = a.sak_prov
and temp07.cde_svc_loc_attend = a.cde_service_loc)
OR temp07.id_prov_attend = to_char(a.sak_prov) || a.cde_service_loc
OR temp07.id_prov_other = to_char(a.sak_prov) || a.cde_service_loc
OR temp07.id_prov_other_2 = to_char(a.sak_prov) || a.cde_service_loc
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp07.DTE_FINAL) >= :il_prev_18_months
OR NVL(MAX(temp07.DTE_FINAL),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_dntl_dtl temp08
WHERE temp08.sak_prov_perf = a.sak_prov
and temp08.cde_svc_loc_perf = a.cde_service_loc
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp08.DTE_FIRST_SVC) >= :il_prev_18_months
OR NVL(MAX(temp08.DTE_FIRST_SVC),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_dntl_hdr temp09
WHERE ( (temp09.prov_billing = a.sak_prov
and temp09.cde_service_loc = a.cde_service_loc)
OR (temp09.sak_prov_perf = a.sak_prov
and temp09.cde_perf_svc_loc = a.cde_service_loc)
OR (temp09.sak_prov_referring = a.sak_prov
and temp09.cde_svc_loc_ref_1 = a.cde_service_loc)
OR (temp09.sak_prov_referring_2 = a.sak_prov
and temp09.cde_svc_loc_ref_2 = a.cde_service_loc)
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp09.DTE_FINAL) >= :il_prev_18_months
OR NVL(MAX(temp09.DTE_FINAL),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_pharm_hdr temp10
WHERE ( (temp10.prov_billing = a.sak_prov
and temp10.cde_service_loc = a.cde_service_loc)
OR (temp10.sak_prov_rend = a.sak_prov
and temp10.cde_svc_loc_rend = a.cde_service_loc)
OR (temp10.sak_presc_prov = a.sak_prov
and temp10.cde_svc_loc_presc = a.cde_service_loc)
OR temp10.id_prov_prescrb = to_char(a.sak_prov) || a.cde_service_loc
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp10.DTE_FINAL) >= :il_prev_18_months
OR NVL(MAX(temp10.DTE_FINAL),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_phys_dtl temp11
WHERE ( (temp11.sak_prov_perf = a.sak_prov
and temp11.cde_svc_loc_rend = a.cde_service_loc)
OR (temp11.sak_prov_referring = a.sak_prov
and temp11.cde_svc_loc_ref_1 = a.cde_service_loc)
OR (temp11.sak_prov_referring_2 = a.sak_prov
and temp11.cde_svc_loc_ref_2 = a.cde_service_loc)
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp11.DTE_LAST_SVC) >= :il_prev_18_months
OR NVL(MAX(temp11.DTE_LAST_SVC),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_phys_hdr temp12
WHERE ( (temp12.prov_billing = a.sak_prov
and temp12.cde_service_loc = a.cde_service_loc)
OR (temp12.sak_prov_perf = a.sak_prov
and temp12.cde_perf_svc_loc = a.cde_service_loc)
OR (temp12.sak_prov_referring = a.sak_prov
and temp12.cde_svc_loc_ref_1 = a.cde_service_loc)
OR (temp12.sak_prov_referring_2 = a.sak_prov
and temp12.cde_svc_loc_ref_2 = a.cde_service_loc)
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp12.DTE_FINAL) >= :il_prev_18_months
OR NVL(MAX(temp12.DTE_FINAL),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_ub92_dtl temp13
WHERE ( (temp13.sak_pr_other = a.sak_prov
and temp13.cde_scv_loc_other = a.cde_service_loc)
OR (temp13.sak_pr_other_2 = a.sak_prov
and temp13.cde_svc_loc_other_2 = a.cde_service_loc)
OR (temp13.sak_pr_attend = a.sak_prov
and temp13.cde_svc_loc_attend = a.cde_service_loc)
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp13.DTE_LAST_SVC) >= :il_prev_18_months
OR NVL(MAX(temp13.DTE_LAST_SVC),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim01.t_pd_ub92_hdr temp14
WHERE ( (temp14.prov_billing = a.sak_prov
and temp14.cde_service_loc = a.cde_service_loc)
OR (temp14.sak_pr_facility = a.sak_prov
and temp14.cde_svc_loc_fa = a.cde_service_loc)
OR (temp14.sak_pr_other_2 = a.sak_prov
and temp14.cde_svc_loc_other_2 = a.cde_service_loc)
OR (temp14.sak_pr_attend = a.sak_prov
and temp14.cde_svc_loc_attend = a.cde_service_loc)
OR (temp14.sak_pr_other = a.sak_prov
and temp14.cde_svc_loc_other = a.cde_service_loc)
OR temp14.id_prov_attend = to_char(a.sak_prov) || a.cde_service_loc
OR temp14.id_prov_other = to_char(a.sak_prov) || a.cde_service_loc
OR temp14.id_prov_other_2 = to_char(a.sak_prov) || a.cde_service_loc
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp14.DTE_FINAL) >= :il_prev_18_months
OR NVL(MAX(temp14.DTE_FINAL),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_dental_dtl temp15
WHERE temp15.sak_prov_perf = a.sak_prov
and temp15.cde_svc_loc_perf = a.cde_service_loc
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp15.DTE_FIRST_SVC) >= :il_prev_18_months
OR NVL(MAX(temp15.DTE_FIRST_SVC),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_dental_hdr temp16
WHERE ( (temp16.sak_prov_perf = a.sak_prov
and temp16.cde_perf_svc_loc = a.cde_service_loc)
OR (temp16.sak_prov_referring = a.sak_prov
and temp16.cde_svc_loc_ref_1 = a.cde_service_loc)
OR (temp16.sak_prov_referring_2 = a.sak_prov
and temp16.cde_svc_loc_ref_2 = a.cde_service_loc)
OR (temp16.prov_billing = a.sak_prov
and temp16.cde_service_loc = a.cde_service_loc)
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING ((MAX(temp16.DTE_LAST_SVC) >= :il_prev_18_months
OR NVL(MAX(temp16.DTE_LAST_SVC),0) = 0)
and (MAX(temp16.DTE_BILLED) >= :il_prev_18_months
OR NVL(MAX(temp16.DTE_BILLED),0) = 0) )
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_phrm_hdr temp17
WHERE ( (temp17.prov_billing = a.sak_prov
and temp17.cde_service_loc = a.cde_service_loc)
OR (temp17.sak_prov_rend = a.sak_prov
and temp17.cde_svc_loc_rend = a.cde_service_loc)
OR (temp17.sak_presc_prov = a.sak_prov
and temp17.cde_svc_loc_presc = a.cde_service_loc)
OR temp17.id_prov_prescrb = to_char(a.sak_prov) || a.cde_service_loc
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp17.DTE_BILLED) >= :il_prev_18_months
OR NVL(MAX(temp17.DTE_BILLED),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_phys_dtl temp18
WHERE ( (temp18.sak_prov_perf = a.sak_prov
and temp18.cde_svc_loc_rend = a.cde_service_loc)
OR (temp18.sak_prov_referring = a.sak_prov
and temp18.cde_svc_loc_ref_1 = a.cde_service_loc)
OR (temp18.sak_prov_referring_2 = a.sak_prov
and temp18.cde_svc_loc_ref_2 = a.cde_service_loc)
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp18.DTE_LAST_SVC) >= :il_prev_18_months
OR NVL(MAX(temp18.DTE_LAST_SVC),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_phys_hdr temp19
WHERE ( (temp19.prov_billing = a.sak_prov
and temp19.cde_service_loc = a.cde_service_loc)
OR (temp19.sak_prov_perf = a.sak_prov
and temp19.cde_perf_svc_loc = a.cde_service_loc)
OR (temp19.sak_prov_referring = a.sak_prov
and temp19.cde_svc_loc_ref_1 = a.cde_service_loc)
OR (temp19.sak_prov_referring_2 = a.sak_prov
and temp19.cde_svc_loc_ref_2 = a.cde_service_loc)
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING ((MAX(temp19.DTE_LAST_SVC) >= :il_prev_18_months
OR NVL(MAX(temp19.DTE_LAST_SVC),0) = 0)
and (MAX(temp19.DTE_BILLED) >= :il_prev_18_months
OR NVL(MAX(temp19.DTE_BILLED),0) = 0) )
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_ub92_dtl temp20
WHERE ( (temp20.sak_pr_other = a.sak_prov
and temp20.cde_scv_loc_other = a.cde_service_loc)
OR (temp20.sak_pr_other_2 = a.sak_prov
and temp20.cde_svc_loc_other_2 = a.cde_service_loc)
OR (temp20.sak_pr_attend = a.sak_prov
and temp20.cde_svc_loc_attend = a.cde_service_loc)
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp20.DTE_LAST_SVC) >= :il_prev_18_months
OR NVL(MAX(temp20.DTE_LAST_SVC),0) = 0
union
select a.sak_prov, a.cde_service_loc, a.sak_short from pr_php_elig_tmp a, aim00.t_susp_ub92_hdr temp22
WHERE ( (temp22.prov_billing = a.sak_prov
and temp22.cde_service_loc = a.cde_service_loc)
OR (temp22.sak_pr_facility = a.sak_prov
and temp22.cde_svc_loc_fa = a.cde_service_loc)
OR (temp22.sak_pr_other_2 = a.sak_prov
and temp22.cde_svc_loc_other_2 = a.cde_service_loc)
OR (temp22.sak_pr_attend = a.sak_prov
and temp22.cde_svc_loc_attend = a.cde_service_loc)
OR (temp22.sak_pr_other = a.sak_prov
and temp22.cde_svc_loc_other = a.cde_service_loc)
OR temp22.id_prov_attend = to_char(a.sak_prov) || a.cde_service_loc
OR temp22.id_prov_other = to_char(a.sak_prov) || a.cde_service_loc
OR temp22.id_prov_other_2 = to_char(a.sak_prov) || a.cde_service_loc
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX(temp22.DTE_BILLED) >= :il_prev_18_months
OR NVL(MAX(temp22.DTE_BILLED),0) = 0
);Perhaps an approach like this would work better. No promises, but it's worth a try.
SELECT *
FROM pr_php_elig_tmp a
WHERE NOT EXISTS (
SELECT a.sak_prov,
a.cde_service_loc,
a.sak_short
FROM aim01.t_deny_dntl_dtl temp01
WHERE temp01.sak_prov_perf = a.sak_prov
AND temp01.cde_svc_loc_perf = a.cde_service_loc
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX (temp01.dte_first_svc) >= :il_prev_18_months
OR NVL (MAX (temp01.dte_first_svc), 0) = 0)
AND NOT EXISTS (
SELECT a.sak_prov,
a.cde_service_loc,
a.sak_short
FROM aim01.t_deny_dntl_hdr temp02
WHERE ( ( temp02.prov_billing = a.sak_prov
AND temp02.cde_service_loc = a.cde_service_loc)
OR ( temp02.sak_prov_perf = a.sak_prov
AND temp02.cde_perf_svc_loc = a.cde_service_loc)
OR ( temp02.sak_prov_referring = a.sak_prov
AND temp02.cde_svc_loc_ref_1 = a.cde_service_loc)
OR ( temp02.sak_prov_referring_2 = a.sak_prov
AND temp02.cde_svc_loc_ref_2 = a.cde_service_loc))
GROUP BY a.sak_prov, a.cde_service_loc, a.sak_short
HAVING MAX (temp02.dte_final) >= :il_prev_18_months
OR NVL (MAX (temp02.dte_final), 0) = 0) -
SQL Query : Order By issue with HUGE Table
Hello friends,
I have been through a terrible issue with order by. I would appreciate your help. Please let me know, your input for my case:
=> if i run select query it returns result quick in some milliseconds. (sql dev. fetches 50 rows at a time)
=> if i run select query with where condition and column (say A) in where condition is even indexed and i have order by and that order by column (say B) is also indexed.
Now, here is the issue:
1. if no. of rows with that where condition can filter yielding small result set then order by works fine .. 1-5 sec which is good.
2.*if no. of rows with that where condition can filter yielding Large result set, say more than 50,000 then with order by then the wait time is exponential.... i have even waited 10+ mins to get the result back for 120,000 records.*
Is order by takes that long for 100K records ... i think something else if wrong... your pointer will really be helpful... i am very new to sql and even newer for large table case.
I am using SQL Developer Version 2.1.1.64
and Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
Thank you so much.
Edited by: 896719 on Jan 11, 2013 8:38 AMYes you are correct, but my concentration was on order by thing, so it will do full scan of table so i was putting that ... and was also wondering if millions of record in table should not be a issue...???
Any way for the explain plan , when just a value in the where changes there is the huge difference i want to point out too as below:
SELECT
FROM
EES_EVT EES_EVT where APLC_EVT_CD= 'ABC' ORDER BY CRE_DTTM DESC
execution time : 0.047 sec
Plan hash value: 290548126
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 27 | 14688 | 25 (4)| 00:00:01 |
| 1 | SORT ORDER BY | | 27 | 14688 | 25 (4)| 00:00:01 |
| 2 | TABLE ACCESS BY INDEX ROWID| EES_EVT | 27 | 14688 | 24 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | XIE1EES_EVT | 27 | | 4 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - access("APLC_EVT_CD"='ABC')
Note
- SQL plan baseline "SYS_SQL_PLAN_6d41e6b91925c463" used for this statement
=============================================================================================
SELECT
FROM
EES_EVT EES_EVT where APLC_EVT_CD= 'XYZ' ORDER BY CRE_DTTM DESC
execution : 898.672 sec.
Plan hash value: 290548126
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 121K| 62M| | 102K (1)| 00:11:02 |
| 1 | SORT ORDER BY | | 121K| 62M| 72M| 102K (1)| 00:11:02 |
| 2 | TABLE ACCESS BY INDEX ROWID| EES_EVT | 121K| 62M| | 88028 (1)| 00:09:27 |
|* 3 | INDEX RANGE SCAN | XIE1EES_EVT | 121K| | | 689 (1)| 00:00:05 |
Predicate Information (identified by operation id):
3 - access("APLC_EVT_CD"='XYZ')
Note
- SQL plan baseline "SYS_SQL_PLAN_ef5709641925c463" used for this statementAlso Note this table contains 74328 MB data in it.
Thanks -
SQL Query Sorting Order issue - Help needed
Hi All,
I am using the following query in my project to display the records in the grid.
/* Formatted on 04-09-2013 PM 8:01:51 (QP5 v5.149.1003.31008) */
SELECT eol,
status_msg,
relation,
building_name,
device_id id,
CEIL (SYSDATE - updated_date) duration,
lab_id,
aisle_id,
aisle_location_id,
ip_address,
port,
slot_num,
hostname,
pid,
description,
sl_num,
eitms_code,
status,
dnd_flag,
aisle,
aisle_location,
spname,
os_version,
user_id,
TO_CHAR (updated_date, 'YYYY-MM-DD HH24:MI:SS') updated_date,
isterm_svr,
net_type,
DEVICE_GROUP_REF,
cmd_id_ref,
LISTAGG (TESTBED_ID, ',') WITHIN GROUP (ORDER BY TESTBED_ID)
AS testbeds_id_ref,
LISTAGG (NAME, ',') WITHIN GROUP (ORDER BY TESTBED_ID)
AS testbeds_names,
spname || '-' || ip_address || '-' || port AS child_asset_group
FROM DEVICE_TESTBED_VW
WHERE lab_id IN
('7099849',
'10769617',
'4258712',
'10513562',
'10515074',
'5882676',
'8330925')
GROUP BY eol,
status_msg,
relation,
device_id,
lab_id,
aisle_id,
aisle_location_id,
ip_address,
port,
slot_num,
hostname,
pid,
description,
sl_num,
eitms_code,
status,
dnd_flag,
aisle,
aisle_location,
spname,
os_version,
user_id,
updated_date,
isterm_svr,
net_type,
DEVICE_GROUP_REF,
cmd_id_ref,
building_name
ORDER BY building_name ASC,
LOWER (child_asset_group) ASC,
LOWER (relation) DESC
The problem is , if any one sorting with any column , the order is not correct
In this below code , i have done sorting by port . But the result data order is not correct .
/* Formatted on 04-09-2013 PM 8:07:02 (QP5 v5.149.1003.31008) */
SELECT eol,
status_msg,
relation,
building_name,
device_id id,
CEIL (SYSDATE - updated_date) duration,
lab_id,
aisle_id,
aisle_location_id,
ip_address,
port,
slot_num,
hostname,
pid,
description,
sl_num,
eitms_code,
status,
dnd_flag,
aisle,
aisle_location,
spname,
os_version,
user_id,
TO_CHAR (updated_date, 'YYYY-MM-DD HH24:MI:SS') updated_date,
isterm_svr,
net_type,
DEVICE_GROUP_REF,
cmd_id_ref,
LISTAGG (TESTBED_ID, ',') WITHIN GROUP (ORDER BY TESTBED_ID)
AS testbeds_id_ref,
LISTAGG (NAME, ',') WITHIN GROUP (ORDER BY TESTBED_ID)
AS testbeds_names,
spname || '-' || ip_address || '-' || port AS child_asset_group
FROM DEVICE_TESTBED_VW
WHERE lab_id IN
('7099849',
'10769617',
'4258712',
'10513562',
'10515074',
'5882676',
'8330925')
GROUP BY eol,
status_msg,
relation,
device_id,
lab_id,
aisle_id,
aisle_location_id,
ip_address,
port,
slot_num,
hostname,
pid,
description,
sl_num,
eitms_code,
status,
dnd_flag,
aisle,
aisle_location,
spname,
os_version,
user_id,
updated_date,
isterm_svr,
net_type,
DEVICE_GROUP_REF,
cmd_id_ref,
building_name
ORDER BY PORT ASC
Can some one help me to fix this issue?Hi,
Sorry, it's not clear what you want.
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Simplify the problem as much as possible. For example, if you really need to GROUP BY 28 columns, post a problem where you need to GROUP BY only 2 or 3 columns. (Just explain that you really have 28, so people will give solutions that are sure to work for all 28).)
Always say which version of Oracle you're using (for example, 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
SQL query group by with concatenation
How can i put the name of the column i concatenated in group by command?
Example is:
tbl_staff
user_id name profile last_name
1 una 0001 astfirst
2 pangalawa 0001 lastsecond
3 pangatlo 0001 lastthird
4 pangapat 0001 lastfourth
5 panglima 0002 lastfifth
tbl_work_assignment
wa_id handled_by status
10 1 active
20 1 active
30 2 closed
40 3 active
50 3 closed
60 3 active
If my Query is:
select s.user_id, s.name, count(wa.wa_id)
from tbl_staff s
left join tbl_work_assignment wa
on wa.handled_by = s.user_id
where profile = '0001' and status = 'active'
group by s.user_id, s.name
I will get this result
s.user_id s.name count(wa.wa_id)
1 una 2
3 pangatlo 2
My question is:
"HOW CAN I CONCATENATE THE 'NAME' AND 'LAST_NAME' COLUMNS AND PUT THEIR COLUMN NAME IN GROUP BY?"
Desired Resultset is:
s.user_id s.name full_name count(wa.wa_id)
1 una una lastfirst 2
3 pangatlo pangatlo lastthird 2
I hope you understood my question.. I can explain further if its not clear. ThanksAnd the proof that Alex's last suggestion works:
SQL> create table tbl_staff (user_id,name,profile,last_name)
2 as
3 select 1, 'una', '0001', 'astfirst' from dual union all
4 select 2, 'pangalawa', '0001', 'lastsecond' from dual union all
5 select 3, 'pangatlo', '0001', 'lastthird' from dual union all
6 select 4, 'pangapat', '0001', 'lastfourth' from dual union all
7 select 5, 'panglima', '0002', 'lastfifth' from dual
8 /
Tabel is aangemaakt.
SQL> create table tbl_work_assignment (wa_id,handled_by,status)
2 as
3 select 10, 1, 'active' from dual union all
4 select 20, 1, 'active' from dual union all
5 select 30, 2, 'closed' from dual union all
6 select 40, 3, 'active' from dual union all
7 select 50, 3, 'closed' from dual union all
8 select 60, 3, 'active' from dual
9 /
Tabel is aangemaakt.
SQL> select s.user_id
2 , s.name
3 , s.name || ' ' || s.last_name full_name
4 , count(wa.wa_id)
5 from tbl_staff s
6 left join tbl_work_assignment wa on wa.handled_by = s.user_id
7 where profile = '0001'
8 and status = 'active'
9 group by s.user_id
10 , s.name
11 , s.last_name
12 /
USER_ID NAME FULL_NAME COUNT(WA.WA_ID)
1 una una astfirst 2
3 pangatlo pangatlo lastthird 2
2 rijen zijn geselecteerd.Regards,
Rob. -
SQL Query, group by or self join?
Hi All,
I have a table with about 100,000 rows.. It is a linking table. I want to filter out some of the data. At the bottom I will put a sample table. I am really after advice if I should be using the group by, or something else. It is really slow, and I really wanted to make a view from the query, but it won't run in realtime (I thought about Materialised views, but the data could change and I would want it updated)
So the data would like like this.
1 1
A 1
B 1
1 A
1 B
2 null/0
And I want to transform it into a result that looks like this.
A 1
B 1
2 0
(I can live with 1 1 as well)
The first query I have come up with is
select
A.TXN, A.ID SCHED_INFO, A.STA ORIG_ACT
from
SELECT
Txn, ID,
STA
FROM TEST_STA
WHERE TXN < 0
) A,
select ID, count(STA)
FROM test_STA
WHERE TXN < 0
group by ID
HAVING count(STA) > 1
) B
where A.ID = B.ID
OR A.STA = '0'
The second I came up with was.
select B.Id , A.id STA
from test_STA A, test_STA B
where A.STA = '0'
AND B.STA != '0'
AND B.STA = A.ID
AND b.TXN < 0
Where the data looks like
create table test_STA
( TXN NUMBER,
ID VARCHAR2(20),
STA VARCHAR2(20) )
insert into test_STA Values (1, '1', '0')
insert into test_STA Values (-1, '1', '1')
insert into test_STA Values (-1, '1', 'A')
insert into test_STA Values (-1, '1', 'B')
insert into test_STA Values (-1, 'A', '1')
insert into test_STA Values (-1, 'B', '1')
insert into test_STA Values (-1, '2', '0')
TXN is the transaction number -1 is current, others (> 0 are old)
What does all this mean..
Well
1 is a parent, with A and B as children.
2 is a parent with no children.
So what I want to do return is Parents with no children, and children but not their parents..
So which path should I continue my efforts down do you think ? The first one, with the group by, or the second one, with the join to it's self.
PaulHi,
If you can guarantee, that every child has also a record then following query returns your result:
select ID, count(*)
from test_STA
group by ID
having count(*) = 1
ID COUNT(*)
2 1
A 1
B 1 -
Using a SQL Query Group by is needed
Hi All,
Scenario Below:
we have 2 Transactions, 5 Lines and each line is having 2 Taxes correspondingly. We have few more formula columns which are calculating based on requirements.
We need to Group the amount at Line level for the one specific TAX.
say: L1 1, L2 2, L3 3, L4 4, L5 5. for one tax having L1, L2 and L3 which needs to be sum up 6
and for other tax needs to sum up to 9.
But, we need to display all the Lines.
Regards,
Reddy.Hi, Reddy,
Use the analytic SUM function instead of the aggregate function if you don't want to get only one line of output per group.
Since I don't have a copy of your table, I'll use the scott.emp table to illustrate.
The following query gets some information about individual employees, along with the total salary of all the employees with the same job:
SELECT job
, ename
, sal
, SUM (sal) OVER (PARTITION BY job) AS total_sal
FROM scott.emp
ORDER BY job
;Output:
JOB ENAME SAL TOTAL_SAL
ANALYST SCOTT 3000 6000
ANALYST FORD 3000 6000
CLERK MILLER 1300 4150
CLERK JAMES 950 4150
CLERK SMITH 800 4150
CLERK ADAMS 1100 4150
MANAGER BLAKE 2850 8275
MANAGER JONES 2975 8275
MANAGER CLARK 2450 8275
PRESIDENT KING 5000 5000
SALESMAN TURNER 1500 5600
SALESMAN MARTIN 1250 5600
SALESMAN WARD 1250 5600
SALESMAN ALLEN 1600 5600Almost all of the aggregate functions (including SUM, AVG, COUNT, MIN, even user-defined aggregate functions like STRAGG) have analytic counterparts. The keyword OVER after the argument list marks the function as analytic.
The analytic PARTITION BY clause corresponds to the aggregate GROUP BY.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
It never hurts to say what version of Oracle you're using. -
SQL Query, please help very urgent
I am a newbie is sql.
I have two tables called test_master and test_detail.
Both tables contains pos_id as common field.
In test_detail got sub_id and to get the people under a given pos_id, I join with pos_id of test_master.
In the where condition, when I give the pos_id, it's returning only
the first level. How can I get the second level and get all the levels?
Any help is highly appreciable.It's very urgent.
Looking forward to hear from you.
Thanks
NewbieOk, I am pasting the description of the master and detail in the order.
Master
EMPLOYEE_NO VARCHAR2(30)
ORGANIZATION_ID NUMBER(15)
ORGANIZATION_NAME VARCHAR2(240)
POSITION_ID NUMBER(15)
POSITION_NAME VARCHAR2(240)
Detail
POSITION_ID NUMBER(15)
SUBORDINATE_ID NUMBER(15)
ORGANIZATION_ID NUMBER(15)
POSITION_NAME VARCHAR2(50)
Here is the sql, I want to get all the subordinates under a given position_id of the master.
Looking forward to hear from you.
select a.employee_no,a.POSITION_ID,a.POSITION_NAME,a.EMPLOYEE_NAME,
b.position_id,b.subordinate_id from portal_employee_master_test a,
portal_structure_test b
where a.POSITION_ID = b.POSITION_ID and a.POSITION_ID='xyz'
and b.position_ID=a.POSITION_ID -
Hello All,
i have the fallowing query:
SELECT dbo.OIGE.DocDate, dbo.OIGE.DocNum, dbo.IGE1.ItemCode, dbo.IGE1.Dscription, dbo.IGE1.Quantity, dbo.OITM.FrgnName, dbo.OITM.OnHand,
dbo.OITM.IsCommited, dbo.OITM.OnOrder
FROM dbo.OIGE INNER JOIN
dbo.IGE1 ON dbo.OIGE.DocEntry = dbo.IGE1.DocEntry INNER JOIN
dbo.OITM ON dbo.IGE1.ItemCode = dbo.OITM.ItemCode
and want to make a commulation of the Quantity per item code.
can you help me?
tahnk you and best regards
SerkanHello Serkan,
If you need one line per item, you have to omit first two fields.
Try this one to see:
SELECT T0.ItemCode, Max(T2.Dscription) 'Description', SUM(T2.Quantity) 'QTY', T0.FrgnName, T0.OnHand, T0.IsCommited, T0.OnOrder
FROM dbo.OIGE T1 INNER JOIN
dbo.IGE1 T2 ON T1.DocEntry = T2.DocEntry INNER JOIN
dbo.OITM T0 ON T2.ItemCode = T0.ItemCode
GROUP BY T0.ItemCode, T0.FrgnName, T0.OnHand, T0.IsCommited, T0.OnOrder
Thanks,
Gordon -
A complicated query , group by issue (I guess)
Hi , on a bad structured database 10g running on Windows XP , I have two tables , one for the clients paid money and the other is for clients invoices , I need to calculate the sum of invoices of one client - which identified by his FirstNAme and LastName minus the sum of his paid money beside oney that already paid when making the invoice for example x buy an item , he made an invoice ith 100$ , he paid immediately 10$ nad then later - this will be on the other table - he paid 40$ , so my final result should be 50$ ,all in respect to the same year, here is what I did
SELECT NVL(SUM(NORMAL_CLIENTS.INV_VALUE), 0) - (NVL(SUM(NORMAL_CLIENTS.PAID), 0) + NVL(SUM(NORMAL_CLIENTS_RECEIPTS.REC_VALUE), 0))
AS EXPR1, NORMAL_CLIENTS.NAME, NORMAL_CLIENTS.SURNAME
FROM NORMAL_CLIENTS INNER JOIN
NORMAL_CLIENTS_RECEIPTS ON NORMAL_CLIENTS.NAME = NORMAL_CLIENTS_RECEIPTS.NAME AND
NORMAL_CLIENTS.SURNAME = NORMAL_CLIENTS_RECEIPTS.SURNAME
WHERE (TO_CHAR(NORMAL_CLIENTS.INV_DATE, 'YYYY') =
(SELECT DATE3
FROM TEMP)) AND (TO_CHAR(NORMAL_CLIENTS_RECEIPTS.REC_DATE, 'YYYY') =
(SELECT DATE3
FROM TEMP TEMP_1))
GROUP BY NORMAL_CLIENTS.NAME, NORMAL_CLIENTS.SURNAME
so this worked for me in one condition , the client has to have records on both table , otherwise it returns null
any help will be much appreciatedHi,
So that we can help you, can you provide us with some DDLs to create the tables, and some INSERTs to populate them with representative data?
You don't need to give the full structure of your tables, just relevant columns for the problem.
Also, to preserve formatting and readability, please use the tag to enclose code snippets.
Thanks. -
XMLdb: SQL query/XPATH/RDF issue
Hello -
a small question about the extraction of data from a XML document using XPATH.
I have modified a local copy of a XML schema (foxml1-0.xsd) in order to add the xdb namespace and a "defaultTable" attribute to be able to store the object in a table called MAPDO
<xsd:element name="digitalObject" xdb:defaultTable="MAPDO">
Then I've registered this XML schema using the statement:
BEGIN
DBMS_XMLSchema.registerSchema(
schemaurl=>'http://www.fedora.info/definitions/1/0/foxml1-0.xsd',
schemadoc=>bfilename('XMLDIR','foxml1-0.xsd'),
CSID=>nls_charset_id('AL32UTF8'));
END;
After that, when I describe the table I get this:
SQL> desc mapdo;
Nom NULL ? Type
TABLE of SYS.XMLTYPE(XMLSchema
"http://www.fedora.info/definitions/1/0/foxml1-0.
xsd" Element "digitalObject") STORAGE Object-relational TYPE
"digitalObject730_T
The next step: I have inserted one XML record in the table.
=> No error. The record is valid.
It contains data from differents namespaces (foxml, rdf, oai_dc...)
my problem:
I can get the values for XML elements from the namespace "foxml" (the main one)
but not from the others. (you can see the XML record at the end of the message)
SELECT
extract(object_value,'/digitalObject/@PID') as PID,
extract(object_value,'/digitalObject/datastream[position()=2]/@ID') as
sObjProp,
extract(object_value,'/digitalObject/datastream[position()=2]/datastreamVersion/
@LABEL') as sLabel,
extract(object_value,'/digitalObject/datastream[position()=2]/datastreamVersion/
@CREATED') as sCreated
FROM mapdo e;
The fields PID, sObjProp and sLabel are well retrieved
But... about RDF data (see the xml record below), it describes links between objects in my database.
<foxml:xmlContent>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rel="info:fedora/fedora-system:def/relations-external#">
<rdf:Description rdf:about="info:fedora/boreal:1437">
<rel:isMemberOf
rdf:resource="info:fedora/boreal:1414"/>
</rdf:Description>
</rdf:RDF>
</foxml:xmlContent>
How can I extract data from rdf:RDF elements ?
SELECT
extract(object_value,'/digitalObject/datastream[position()=2]/datastreamVersion/
xmlContent/RDF/Description') as sLink
FROM mapdo e;
It doesn't work. I get a NULL record.
What's the solution ?
Thank you
Benoit Erken
XML record:
<?xml version="1.0" encoding="UTF-8"?>
<foxml:digitalObject xmlns:foxml="info:fedora/fedora-system:def/foxml#"
xmlns:fedoraxsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:audit="info:fedora/fedora-system:def/audit#"
fedoraxsi:schemaLocation="info:fedora/fedora-system:def/foxml#
http://www.fedora.info/definitions/1/0/foxml1-0.xsd" PID="boreal:1437">
<foxml:objectProperties>
<foxml:property NAME="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
VALUE="FedoraObject"/>
<foxml:property NAME="info:fedora/fedora-system:def/model#state"
VALUE="Active"/>
<foxml:property NAME="info:fedora/fedora-system:def/model#label"
VALUE="Thèses"/>
<foxml:property NAME="info:fedora/fedora-system:def/model#createdDate"
VALUE="2007-05-22T11:35:13.004Z"/>
<foxml:property
NAME="info:fedora/fedora-system:def/view#lastModifiedDate"
VALUE="2007-05-22T11:35:18.412Z"/>
<foxml:property NAME="info:fedora/fedora-system:def/model#contentModel"
VALUE="com.vtls.vital.redrocket.collection"/>
</foxml:objectProperties>
<foxml:datastream ID="AUDIT" STATE="A" CONTROL_GROUP="X"
VERSIONABLE="false">
<foxml:datastreamVersion ID="AUDIT.0" LABEL="Fedora Object Audit Trail"
CREATED="2007-05-22T11:35:13.004Z" MIMETYPE="text/xml"
FORMAT_URI="info:fedora/fedora-system:format/xml.fedora.audit">
<foxml:xmlContent>
<audit:auditTrail
xmlns:audit="info:fedora/fedora-system:def/audit#">
<audit:record ID="AUDREC1">
<audit:process type="Fedora API-M"/>
<audit:action>modifyDatastreamByValue</audit:action>
<audit:componentID>DC</audit:componentID>
<audit:responsibility>fedoraAdmin</audit:responsibility>
<audit:date>2007-05-22T11:35:16.921Z</audit:date>
<audit:justification/>
</audit:record>
<audit:record ID="AUDREC2">
<audit:process type="Fedora API-M"/>
<audit:action>addDatastream</audit:action>
<audit:componentID>RELS-EXT</audit:componentID>
<audit:responsibility>fedoraAdmin</audit:responsibility>
<audit:date>2007-05-22T11:35:18.412Z</audit:date>
<audit:justification/>
</audit:record>
</audit:auditTrail>
</foxml:xmlContent>
</foxml:datastreamVersion>
</foxml:datastream>
<foxml:datastream ID="RELS-EXT" STATE="A" CONTROL_GROUP="X"
VERSIONABLE="true">
<foxml:datastreamVersion ID="RELS-EXT.0" LABEL="Relationship Metadata"
CREATED="2007-05-22T11:35:18.412Z" MIMETYPE="text/xml" SIZE="0">
<foxml:xmlContent>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rel="info:fedora/fedora-system:def/relations-external#">
<rdf:Description rdf:about="info:fedora/boreal:1437">
<rel:isMemberOf
rdf:resource="info:fedora/boreal:1414"/>
</rdf:Description>
</rdf:RDF>
</foxml:xmlContent>
</foxml:datastreamVersion>
</foxml:datastream>
<foxml:datastream ID="DC" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
<foxml:datastreamVersion ID="DC1.0" LABEL="Dublin Core Metadata"
CREATED="2007-05-22T11:35:13.004Z" MIMETYPE="text/xml" SIZE="243">
<foxml:xmlContent>
<oai_dc:dc
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title>Thèses</dc:title>
<dc:identifier>boreal:1437</dc:identifier>
</oai_dc:dc>
</foxml:xmlContent>
</foxml:datastreamVersion>
<foxml:datastreamVersion ID="DC.1" LABEL="Dublin Core Metadata"
CREATED="2007-05-22T11:35:16.921Z" MIMETYPE="text/xml" SIZE="321">
<foxml:xmlContent>
<oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/">
<dc:identifier>boreal:1437</dc:identifier>
<dc:title>Thèses</dc:title>
<dc:description>FUNDP - MED : Département d'Histologie
- Embryologie - Thèses</dc:description>
</oai_dc:dc>
</foxml:xmlContent>
</foxml:datastreamVersion>
</foxml:datastream>
</foxml:digitalObject>Forget this question.
I have found more info here
Re: XMLQuery (XQuery) with namespace -
Urgent= How to Group selected columns in sql query
Hi,
I need some urgent help on the following sql query. I 'm sure there is an easy way to do this but I'm stacked!Any help will be much appreciated!!
I have a query to retrieve the following columns:
I want the first 9 columns to be grouped together (not to be repeated) for any occurence of the last 3 columns (abs.ABSENCE_START_DATE,abs.ABSENCE_END_DATE, abs.DAYS_TAKEN DAYS_TAKEN_analysis)
SELECT DISTINCT
sum.employee_number ,
sum.EMPLOYEE_NAME,
sum.EMAIL_ADDRESS,
sum.ORGANIZATION ,
sum.BCEBF ,
sum.ALDE ,
sum.CURYRREMDAYS ,
sum.DAYS_TAKEN ,
sum.REMBCE ,
abs.ABSENCE_START_DATE
abs.ABSENCE_END_DATE,
abs.DAYS_TAKEN DAYS_TAKEN_analysis
--TO_CHAR(TO_CHAR(abs.ABSENCE_START_DATE)||' '||TO_CHAR(abs.ABSENCE_END_DATE)||' '||TO_CHAR(abs.DAYS_TAKEN)) DAYS_TAKEN_ANAL
FROM
HB_V_ANNUAL_LEAVE_SUMMARY_REP SUM,
HB_V_AN_LEAV_DAYS_TAKEN_REP ABS
WHERE
sum.employee_number = abs.EMPLOYEE_NUMBER
ORDER BY
sum.employee_number ,
sum.EMPLOYEE_NAME,
sum.EMAIL_ADDRESS,
sum.ORGANIZATION ,
sum.BCEBF ,
sum.ALDE ,
sum.CURYRREMDAYS ,
sum.DAYS_TAKEN ,
sum.REMBCE
Any feedback/help on how to do this will be highly appreciated.
Thanks a lot
ElenaPlease help!!
I used the break command to group columns that I do not want to repeat in my query output. When I run the query without formatting is working. But when I put all formatting to produce the required output I dont get the result I want.
Below is the exact sql query I use:
<<
SET TERMOUT OFF
SET ECHO OFF
SET ARRAY 35
SET HEA OFF
SET FEEDBACK OFF
SET PAGES 2000
col beginLINE format A100
col winsecidLINE format A100
col placeLINE format A100
COL LINEempty1 format A100
COL LINEempty2 format A100
COL LINEempty3 format A100
COL LINEempty4 format A100
COL LINEempty5 format A100
COL LINEempty6 format A100
COL LINEempty7 format A100
COL LINEempty8 format A100
COL LINEempty9 format A100
COL LINEempty10 format A100
col LINECOLempty format A100
col receiverLINE FORMAT A100
COL EMP_EMAIL_ADDRESS FORMAT A100
COL LINEHEADER FORMAT A100
COL unitsLINE FORMAT A100
COL lmLINE FORMAT A100
COL INTITLE FORMAT A100
COL LINECOL1 FORMAT A100
COL CIF FORMAT A100
COL EMPLOYEE_NAME FORMAT A100
COL ORGANIZATION FORMAT A100
COL LINECOL2 FORMAT A100
COL ALHEADER FORMAT A100
col LINECOL3 FORMAT A100
col BCEBF FORMAT A100
col ALDE FORMAT A100
COL CURYRREMDAYS FORMAT A100
COL DAYS_TAKEN FORMAT A100
col LINECOL4 FORMAT A100
COL REMBCE FORMAT A100
col LINECOL5 FORMAT A100
col LINECOL6 FORMAT A100
col ALHEADER2 FORMAT A100
col LINECOL7 FORMAT A100
col endLINE FORMAT A100
break on beginLINE on winsecidLINE on placeLINE on LINEempty1 ON LINEempty2 ON LINEempty3 ON LINEempty4 ON LINEempty5 ON LINEempty6 ON LINEempty7 ON LINEempty8 ON LINEempty9 ON LINEempty10 on receiverLINE on EMP_EMAIL_ADDRESS on LINEHEADER on unitsLINE on lmLINE on INTITLE on LINECOL1 on CIF on EMPLOYEE_NAME on ORGANIZATION on LINECOL2 on ALHEADER on LINECOL3 on BCEBF on ALDE on CURYRREMDAYS on DAYS_TAKEN on LINECOL4 on REMBCE on LINECOL5 on LINECOL6 on ALHEADER2 on LINECOL7 ON LINEempty11 ON endREPORT on endLINE
SPOOL C:\FORMATout.txt
SELECT
'{{begin}} '||chr(10) beginLINE,
'{{winsecid 999999}} '||chr(10) winsecidLINE,
'{{place rbsemail.tif 0 0}} '||chr(10) placeLINE,
' '||chr(10) LINEempty1,
' '||chr(10) LINEempty2,
' '||chr(10) LINEempty3,
' '||chr(10) LINEempty4,
' '||chr(10) LINEempty5,
' '||chr(10) LINEempty6,
' '||chr(10) LINEempty7,
' '||chr(10) LINEempty8,
' '||chr(10) LINEempty9,
' '||chr(10) LINEempty10,
'{{from [email protected]}} '||chr(10) receiverLINE,
'{{fax '|| EMAIL_ADDRESS||' }} '||chr(10) EMP_EMAIL_ADDRESS,
'{{Subject Annual Leave Summary Report as at '||sysdate||' }} '||chr(10) LINEHEADER,
'{{units cm}} '||chr(10) unitsLINE,
'{{lm 2.0}} '||chr(10) lmLINE,
'ANNUAL LEAVE SUMMARY REPORT AS AT '||sysdate INTITLE,
'---------------------------------------------------------------------' LINECOL1,
'CIF: '||CIF CIF,
'EMPLOYEE NAME: '||EMPLOYEE_NAME EMPLOYEE_NAME,
'DEPARTMENT DETAILS: '||ORGANIZATION ORGANIZATION,
'---------------------------------------------------------------------' LINECOL2,
'ANNUAL LEAVE DETAILS:' ALHEADER,
'---------------------------------------------------------------------' LINECOL3,
'BALANCE B/F FROM PREVIOUS YEAR: '||BCEBF BCEBF,
'DAYS ENTITLED FOR THE CURRENT YEAR: '||ALDE ALDE,
'CURRENT YEAR REMAINING DAYS: '||CURYRREMDAYS CURYRREMDAYS,
'DAYS TAKEN FOR THE CURRENT YEAR: '||DAYS_TAKEN DAYS_TAKEN,
'---------------------------------------------------------------------' LINECOL4,
'REMAINING BALANCE: '||REMBCE REMBCE,
'---------------------------------------------------------------------' LINECOL5,
'---------------------------------------------------------------------' LINECOL6,
'ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:' ALHEADER2,
'---------------------------------------------------------------------' LINECOL7,
TO_CHAR('START DATE: '||ABSENCE_START_DATE||' '||'END DATE: '||ABSENCE_END_DATE||' '||'DAYS TAKEN : '||DAYS_TAKEN_ANAL) AL_DAYS_ANAL,
' '||chr(10) LINEempty11,
'-- End of Report -- '||chr(10) endREPORT,
'{{end}} '||chr(10) endLINE
FROM HB_V_AN_LEAV_SUM_DAYSTAKEN_REP
WHERE CIF IN ('098033','098024')
ORDER BY
beginLINE ,
winsecidLINE,
placeLINE ,
LINEempty1,
LINEempty2,
LINEempty3,
LINEempty4,
LINEempty5,
LINEempty6,
LINEempty7,
LINEempty8,
LINEempty9,
LINEempty10,
receiverLINE,
EMP_EMAIL_ADDRESS,
LINEHEADER ,
unitsLINE ,
lmLINE ,
INTITLE ,
LINECOL1,
CIF ,
EMPLOYEE_NAME ,
ORGANIZATION ,
LINECOL2 ,
ALHEADER ,
LINECOL3,
BCEBF ,
ALDE ,
CURYRREMDAYS ,
DAYS_TAKEN ,
LINECOL4 ,
REMBCE ,
LINECOL5 ,
LINECOL6 ,
ALHEADER2 ,
LINECOL7 ,
LINEempty11,
endREPORT,
endLINE
spool off
>>
The required output I want to get is:
<<
{{begin}}
{{winsecid 750612}}
{{place rbsemail.tif 0 0}}
{{from [email protected]}}
{{fax [email protected] }}
{{Subject Annual Leave Summary Report as at 04-APR-08 }}
{{units cm}}
{{lm 2.0}}
ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
CIF: 098024
EMPLOYEE NAME: Christou Christos Panteli
DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
ANNUAL LEAVE DETAILS:
BALANCE B/F FROM PREVIOUS YEAR: 9
DAYS ENTITLED FOR THE CURRENT YEAR: 27
CURRENT YEAR REMAINING DAYS: 24
DAYS TAKEN FOR THE CURRENT YEAR: -3
REMAINING BALANCE: 33
ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
START DATE: 04-JAN-08 END DATE: 04-JAN-08 DAYS TAKEN : 1
START DATE: 24-JAN-08 END DATE: 24-JAN-08 DAYS TAKEN : 1
START DATE: 20-FEB-08 END DATE: 20-FEB-08 DAYS TAKEN : 1
-- End of Report --
{{end}}
{{begin}}
{{winsecid 750612}}
{{place rbsemail.tif 0 0}}
{{from [email protected]}}
{{fax [email protected]}}
{{Subject Annual Leave Summary Report as at 04-APR-08 }}
{{units cm}}
{{lm 2.0}}
ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
CIF: 098033
EMPLOYEE NAME: Demetriou Elena Steliou
DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
ANNUAL LEAVE DETAILS:
BALANCE B/F FROM PREVIOUS YEAR: 15
DAYS ENTITLED FOR THE CURRENT YEAR: 27
CURRENT YEAR REMAINING DAYS: 25
DAYS TAKEN FOR THE CURRENT YEAR: -2
REMAINING BALANCE: 40
ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
START DATE: 15-JAN-08 END DATE: 15-JAN-08 DAYS TAKEN : 1
START DATE: 24-MAR-08 END DATE: 24-MAR-08 DAYS TAKEN : 1
-- End of Report --
{{end}}
>>
However the actual output we get from the above query is as follows:
<<
{{begin}}
{{winsecid 750612}}
{{place rbsemail.tif 0 0}}
{{from [email protected]}}
{{fax [email protected] }}
{{Subject Annual Leave Summary Report as at 04-APR-08 }}
{{units cm}}
{{lm 2.0}}
ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
CIF: 098024
EMPLOYEE NAME: Christou Christos Panteli
DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
ANNUAL LEAVE DETAILS:
BALANCE B/F FROM PREVIOUS YEAR: 9
DAYS ENTITLED FOR THE CURRENT YEAR: 27
CURRENT YEAR REMAINING DAYS: 24
DAYS TAKEN FOR THE CURRENT YEAR: -3
REMAINING BALANCE: 33
ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
START DATE: 04-JAN-08 END DATE: 04-JAN-08 DAYS TAKEN : 1
-- End of Report --
{{end}}
START DATE: 24-JAN-08 END DATE: 24-JAN-08 DAYS TAKEN : 1
START DATE: 20-FEB-08 END DATE: 20-FEB-08 DAYS TAKEN : 1
{{fax [email protected] }}
{{Subject Annual Leave Summary Report as at 04-APR-08 }}
{{units cm}}
{{lm 2.0}}
ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
CIF: 098033
EMPLOYEE NAME: Demetriou Elena Steliou
DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
ANNUAL LEAVE DETAILS:
BALANCE B/F FROM PREVIOUS YEAR: 15
DAYS ENTITLED FOR THE CURRENT YEAR: 27
CURRENT YEAR REMAINING DAYS: 25
DAYS TAKEN FOR THE CURRENT YEAR: -2
REMAINING BALANCE: 40
ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
START DATE: 15-JAN-08 END DATE: 15-JAN-08 DAYS TAKEN : 1
-- End of Report --
{{end}}
START DATE: 24-MAR-08 END DATE: 24-MAR-08 DAYS TAKEN : 1
>>
IF ANYONE CAN HELP ON THIS I WOULD REALLY APPRECIATE IT!
THANKS A LOT!
Best regards,
Elena -
Issue in creation of group in oim database through sql query.
hi guys,
i am trying to create a group in oim database through sql query:
insert into ugp(ugp_key,ugp_name,ugp_create,ugp_update,ugp_createby,ugp_updateby,)values(786,'dbrole','09-jul-12','09-jul-12',1,1);
it is inserting the group in ugp table but it is not showing in admin console.
After that i also tried with this query:
insert into gpp(ugp_key,gpp_ugp_key,gpp_write,gpp_delete,gpp_create,gpp_createby,gpp_update,gpp_updateby)values(786,1,1,1,'09-jul-12',1,'09-jul-12',1);
After that i tried with this query.but still no use.
and i also tried to assign a user to the group through query:
insert into usg(ugp_key,usr_key,usg_priority,usg_create,usg_update,usg_createby,usg_updateby)values(4,81,1,'09-jul-12','09-jul-12',1,1);
But still the same problem.it is inserting in db.but not listing in admin console.
thanks,
hanuman.Hanuman Thota wrote:
hi vladimir,
i didn't find this 'ugp_seq'.is this a table or column?where is it?
It is a sequence.
See here for details on oracle sequences:
http://www.techonthenet.com/oracle/sequences.php
Most of the OIM database schema is created with the following script, located in the RCU distribution:
$RCU_HOME/rcu/integration/oim/sql/xell.sql
there you'll find plenty of sequence creation directives like:
create sequence UGP_SEQ
increment by 1
start with 1
cache 20
to create a sequence, and
INSERT INTO UGP (UGP_KEY, UGP_NAME, UGP_UPDATEBY, UGP_UPDATE, UGP_CREATEBY, UGP_CREATE,UGP_ROWVER, UGP_DATA_LEVEL, UGP_ROLE_CATEGORY_KEY, UGP_ROLE_OWNER_KEY, UGP_DISPLAY_NAME, UGP_ROLENAME, UGP_DESCRIPTION, UGP_NAMESPACE)
VALUES (ugp_seq.nextval,'SYSTEM ADMINISTRATORS', sysadmUsrKey , SYSDATE,sysadmUsrKey , SYSDATE, hextoraw('0000000000000000'), 1, roleCategoryKey, sysadmUsrKey, 'SYSTEM ADMINISTRATORS', 'SYSTEM ADMINISTRATORS', 'System Administrator role for OIM', 'Default');
as a sequence usage example.
Regards,
Vladimir
Maybe you are looking for
-
I'm including a .png file that shows how I've coded this array. This is part of a subvi. Do arrays/loops behave differently in subvi's than in vi's? Attachments: arrays and loops.png 29 KB
-
[JS][CS3] Simple dialog box problem
Hi I am wanting to make my script do 1 of 2 things depending on the result of a dialog box. I cannot seem to register the users response. Here is the code: var myDialog = new Window('dialog', 'Confirm Changes'); myDialog.frameLocation = [600,400];
-
Bug in Acrobat Reader Plugin for FF?
Hi, i use a web application which pulls pdf reports from a server by http-post requests, so parameters are transmitted in the requests-body. As a viewer i do use Acrobat Reader Plugin, most recent release with FF 3.0.3 on Windows XP pro. So due of th
-
since i installed the new xfi2 firmaware my computer only recognizes my player for about 0 seconds before it closes it.
-
I have a CQ61-429us that stopped working. When I power on I get all the lights, the HDD and CD drives spin, and sound like they are fine. I always have a black screen, so I tried hooking up to an external monitor, with no video signal even after func