MP-BGP query need help
Hi Experts,
I've gone through so many mpls documents and I believe i have a decent grasp of how it works but applying those principles i appear to be stuck in a setup that just won't work.
The setup is pretty straigh forward: R1 is connected to R2 and R2 is connected to R3.
R1 has ospf peering with R2 and R2 has ospf peering with R3.
OSPF working fine and connectivity via Lo on all routers working.
R1 has MP-BGP bgp peering with R3 where R1 and R3 is advertising its Lo100 interface to each other.
BGP working fine and I can see from R1 the Lo100 ip of R3 on the vrf myvrf routing table of R1.
When I do a show ip route vrf myvrf on R1, route to Lo100 of R3 (99.1.1.3) has an egress of 5.1.1.3 (default global table).
But when i try to ping from R1, 'ping vrf myvrf 99.1.1.3 source 99.1.1.1' , ping fails.
Documentation says that this should work but apparently it doesn't for me; am not sure what i am missing here.
I even tried to leak the route on both R1 and R3. But still no go.
R1:
ip route vrf myvrf 5.1.1.3 255.255.255.255 f0/0 1.1.1.2
R3:
ip route vrf myvrf 5.1.1.1 255.255.255.255 f0/0 2.1.1.1
Don't know what i am doing wrong here. And to be honest am getting confused. Please help.
Setup is as follows:
R1:
int f0/0
ip 1.1.1.1 255.255.255.0
mpls ip
int Lo0
ip add 5.1.1.1
int Lo100
ip vrf forwarding myvrf
ip add 99.1.1.1 255.255.255.255
ip vrf myvrf
rd 10:20
route-target both 10:20
router ospf 1
router-id 5.1.1.1
network 1.1.1.0 0.0.0.255 area 0
network 5.1.1.3 0.0.0.0.0 area 0
router bgp 10
neighbor 5.1.1.3 remote-as 10
no neighbor 5.1.1.3 active
neighbor 5.1.1.3 update-source Lo0
address-family vpnv4
neighbor 5.1.1.3 activate
neighbor 5.1.1.3 send-community both
address-family ipv4 vrf myvrf
network 99.1.1.1 mask 255.255.255.255
R2:
int f0/0
ip add 1.1.1.2 255.255.255.0
mpls ip
int f1/0
ip add 2.1.1.1 255.255.255.0
mpls ip
int Lo0
ip add 5.1.1.2 255.255.255.0
router ospf 1
router-id 5.1.1.2
network 1.1.1.0 0.0.0.255 area 0
network 2.1.1.0 0.0.0.255 area 0
network 5.1.1.2 0.0.0.0 area 0
R3:
int f0/0
ip add 2.1.1.2 255.255.255.0
mpls ip
int Lo0
ip add 5.1.1.3 255.255.255.0
int Lo100
ip vrf forwarding myvrf
ip add 99.1.1.3 255.255.255.255
router ospf 1
network 2.1.1.0 0.0.0.255 area 0
network 5.1.1.2 0.0.0.0 area 0
router bgp 10
neighbor 5.1.1.1 remote-as 10
no neighbor 5.1.1.1 activate
neighbor 5.1.1.1 update-source Lo0
address-family vpnv4
neighbor 5.1.1.3 activate
neighbor 5.1.1.3 send-community both
address-family ipv4 vrf myvrf
network 99.1.1.3 mask 255.255.255.255
Hello Marcusbrutus,
blau grana is right you have an issue with loopback addresses subnet masks.
Your control plane looks like fine because you have all the expected MP BGP VPNv4 routes in place, but the forwarding plane is broken.
MPLS L3 VPN packets are sent within the LSP with destination the remote PE loopback address so from R1 point of view is R3's L0.
If you go on R2 device and you check the state of MPLS forwarding for R3 L0 IP address you will see that instead of seeing a POP TAG action you will see an untagged action.
The reason for the wrong LSP binding is the subnet mask on R3 loopback address: OSPF advertises all loopback addresses with a /32 mask by default, but the subnet mask is different. LDP carries the configured subnet mask. But installation of labels is made after check with IGP (OSPF in this case).
As a result of this the R2 router cannot install the correct POP TAG = implicit null label as action to do to reach R3 L0.
With POP TAG action the R2 router removes the external label (POP a label) and sends a packet (with MPLS ethertype on ethernet) with a single label MPLS stack to the egress PE R3. R3 sees a label associated to the VRF and it is able to route the packet to the appropriate interface.
With untagged action R2 removes a label take all the packet content and sends it as it was an IP packet to the downstream device. (with ethertype 0x800 on ethernet) The downstream device finds a packet that is supposed to be an IP packet but it isn't (for the inner label still there) and silently drops it.
This is what we had seen in lab tests.
To solve this issue you should:
use /32 loopback addresses this the recommended best practice
or you can still use non overlapping non /32 loopback addresses but you need to add the command ip ospf network point-to-point under loopback configuration as this makes OSPF to advertise the true IP subnet mask
Hope to help
Giuseppe
Similar Messages
-
What's wrong with this query--need help
Requirement: need to get the names of employees who were hired on tuesday this has to use to_char function
select ename
from emp
where to_char(hiredate,'day')='tuesday';
when i execute the query
o/p is no rows selected
please help.
thanks in advance.Hi,
861173 wrote:
Requirement: need to get the names of employees who were hired on tuesday this has to use to_char function
select ename
from emp
where to_char(hiredate,'day')='tuesday';
when i execute the query
o/p is no rows selected Try:
WHERE TO_CHAR (hiredate, 'fmday') = 'tuesday'Without 'FM" in the 2nd argument, TO_CHAR pads the results to make it a consistent length. If your NLS_DATE_LANGUAGE=ENGLISH, that means it will always return a 9-character string, since the longest name in English ('Wednesday') has 9 letters. 'FM' (case-insernsitive) tells TO_CHAR not to add that kind of padding. -
Row_number query - need help ASAP
Hi ,
Need some help bout query
I need a query for display output like below
DATE CODE MAC_NO BATCH_NO
01-OCT-07 1119 02 1
20-OCT-07 1210 01 2
01-NOV-07 1209 01 3
01-NOV-07 1510 01 4
01-NOV-07 4025 01 5
01-NOV-07 4025 01 5
01-NOV-07 4051 03 6
02-NOV-07 1209 01 7
i hv no idea how to do it. My query doesn't work for tat requirement.Tis is my query
SELECT date
,code
,mac_no
,ROW_NUMBER()
OVER (PARTITION by date,code,mac_no
ORDER by date,code,mac_no)
as batch_no
FROM PAYMENT
WHERE npcs_cycle_num = 27
AND txn_insert_seq_num > 0;
The output juz like below.I need everybody help ASAP.
DATE CODE MAC_NO BATCH_NO
01-OCT-07 1119 02 1
20-OCT-07 1210 01 1
01-NOV-07 1209 01 1
01-NOV-07 1510 01 1
01-NOV-07 4025 01 1
01-NOV-07 4025 01 2
01-NOV-07 4051 03 1
02-NOV-07 1209 01 1
Thanks
CTI'm sorry..Maybe my words it not that clear enough. You were right about how ROW_NUMBER works (it
assigns a numeric value and resets based on the grouping you specify in the PARTITION clause).
What I want actually is the row number increment based on the txn_date,poc_code and machine_no.
I'm not sure whether using the row_number() can solve my solutions. I really hope that you could help me.
I thought of using row_number() may help. Do you have any other solution?
Here is my table description.
DESC PAYMENT;
Name Null? Type
TXN_ID_NUM NOT NULL NUMBER(12)
ACCT_NO NOT NULL VARCHAR2(14)
CANCEL_CODE VARCHAR2(5)
ADJ_TYPE_NO VARCHAR2(2)
REASON_CODE VARCHAR2(5)
CASHIER_ID_NO VARCHAR2(10)
SUPERVISOR_ID_NO VARCHAR2(10)
REV_CODE VARCHAR2(5)
TXN_DATE DATE
PAY_ADJ_DATE DATE
POC_CODE VARCHAR2(10)
MACHINE_NO VARCHAR2(3)
PAY_MODE_CODE VARCHAR2(5)
ORIG_ACCT_NO VARCHAR2(14)
PAY_AMT NUMBER(12,2)
INVOICE_NO VARCHAR2(20)
PAY_RECEIPT_NO VARCHAR2(24)
PAY_BATCH_NO VARCHAR2(20)
NPCS_CYCLE_NUM NUMBER(4)
TXN_INSERT_SEQ_NUM NOT NULL NUMBER(12)
2) Below is the query before assigning the row number:
SQL> SELECT TXN_DATE,POC_CODE,MACHINE_NO,PAY_BATCH_NO,PAY_AMT,REV_CODE,ADJ_TYPE_NO,PAY_MODE_CODE
2 FROM PAYMENT
3 WHERE NPCS_CYCLE_NUM=27
4 AND REV_CODE IN (SELECT rev_code
5 FROM OUTBND_REV_CODE
6 WHERE outbnd_agen_file_code = 'TMB'
7 AND sys_appl_id ='CCC')
8 ORDER BY TXN_DATE,POC_CODE,MACHINE_NO;
TXN_DATE POC_CODE MAC PAY_BATCH_NO PAY_AMT REV_C AD PAY_M
01-OCT-07 1119 02 20071101120900000000 154.25 017 85 1
20-OCT-07 1210 01 20071101402501400000 444.02 017 00 5
01-NOV-07 1209 01 20071101120901100000 585.32 017 85 1
01-NOV-07 1510 01 20071101402501100000 493 014 00 1
01-NOV-07 4025 01 20071101402501100000 203.85 016 00 3
01-NOV-07 4025 01 20071101402501100000 487.96 017 00 1
01-NOV-07 4051 03 20071101402501100000 109.26 016 00 3
02-NOV-07 1209 01 20071102120900000000 105.76 014 00 1
3)This is my query and the result:
SQL> SELECT /* SQL_ID 2703 */
2 txn_date
3 ,poc_code
4 ,machine_no
5 ,pay_batch_no
6 ,pay_amt
7 ,rev_code
8 ,adj_type_no
9 ,pay_mode_code
10 ,ROW_NUMBER()
11 OVER (PARTITION by txn_date,poc_code,machine_no
12 ORDER by txn_date,poc_code,machine_no)
13 as row_number
14 FROM PAYMENT
15 WHERE npcs_cycle_num = 27
16 AND txn_insert_seq_num > 0
17 AND rev_code IN (SELECT rev_code
18 FROM OUTBND_REV_CODE
19 WHERE outbnd_agen_file_code = 'TMB'
20 AND sys_appl_id ='CCC');
TXN_DATE POC_CODE MAC PAY_BATCH_NO PAY_AMT REV_C AD PAY_M ROW_NUMBER
01-OCT-07 1119 02 20071101120900000000 154.25 017 85 1 1 (1)
20-OCT-07 1210 01 20071101402501400000 444.02 017 00 5 1 (2)
01-NOV-07 1209 01 20071101120901100000 585.32 017 85 1 1 (3)
01-NOV-07 1510 01 20071101402501100000 493 014 00 1 1 (4)
01-NOV-07 4025 01 20071101402501100000 203.85 016 00 3 1 (5)
01-NOV-07 4025 01 20071101402501100000 487.96 017 00 1 2 (5)
01-NOV-07 4051 03 20071101402501100000 109.26 016 00 3 1 (6)
02-NOV-07 1209 01 20071102120900000000 105.76 014 00 1 1 (7)
8 rows selected.
What I want actually as in the bracket (group by three fields which are txn_date,poc_code and machine_no)
.I hope this is clearer. -
Heterogeneous Query, need help ASAP!
Post Author: zen69
CA Forum: Data Connectivity and SQL
Hi all! I'm trying to make a report that uses a view with linked table (tables from a linked server).I tested my view in SQL Server and it's working but when I try to use it in my report I get these two error messages:Error #1: Failed to retrieve data from the databaseError #2:
Failed to retrieve data from the database. Details:
42000:[Microsoft][ODBC SQL Server Driver][SQL Server]Heterogeneous queries
require the ANSI_NULLS and ANSI_WARNINGS options to be set for the
connection. This ensures cosistent query semantics. Enable these options and
then reissue your query. [Database Vendor Code: 7405 ]I'm using
Crystal Reports CR Professional; Product Type: FullVersion : 11.0.0.895. Please help me ASAP, I really need it to be done! Thanks,J.B.Post Author: zen69
CA Forum: Data Connectivity and SQL
I forgot to say that I'm using MS SQL Server 2005... -
Trying to form complex query - need help
I have a fairly complex query that I need to join the results of to show actual and goal by day. The actuals are an aggregation of records that get put in every day, while the targets are a single entry in range format indicating an active range for which the target applies. I'm working on a query that will put things together by month and I'm running into a snag. Can someone please point out where appropriate naming needs to go to get this to come together?
This one works:
(select DATE_INDEX, SUM(LDS) as TTLLDS, SUM(TONS) as TTLTONS from
(select DATE_INDEX, VEH_LOC, SUM(LDS) as LDS, SUM(WT) as TONS from
(select c.DATE_INDEX, c.VEH_LOC, COUNT(j.LOAD_JOB_ID) as LDS,
CASE WHEN SUM(w.SPOT_WEIGHT) = 0 THEN SUM(j.MAN_SPOT_WT)
ELSE SUM(w.SPOT_WEIGHT)
END as WT
from TC c, TC_LOAD_JOBS j, LOAD_RATES r, SPOT_WEIGHTS w
where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
and c.DATE_INDEX = w.DATE_INDEX and j.LOAD_RATE_ID = w.LOAD_RATE_ID
and c.VEH_LOC in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
group by c.DATE_INDEX, c.VEH_LOC
union
select c.DATE_INDEX, c.VEH_LOC, COUNT(j.JOB_ID) as LDS,
DECODE(SUM(j.AVG_SPOT_WEIGHT),0,SUM(r.BID_TONS),SUM(j.AVG_SPOT_WEIGHT)) as WT
from TC_3RDPARTY c, TC_3RDPARTY_JOBS j, LOAD_RATES r
where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
and j.FACTORY_ID in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
group by c.DATE_INDEX, c.VEH_LOC)
group by DATE_INDEX, VEH_LOC)
group by DATE_INDEX)Now I need to add in the following query:
select (u.MACH_TPH_D+u.MACH_TPH_N)/2 as MTPH_TGT, (u.LABOR_TPH_D+u.LABOR_TPH_N)/2 as LTPH_TGT
from UTIL_TARGET_LOADERS u
where u.ORG_ID in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)The join needs to be based on VEH_LOC and DAY in the form:
... WHERE u.ORG_ID = x.VEH_LOC
AND x.DATE_INDEX between u.START_DATE and NVL(u.END_DATE,sysdate)I had one that worked just fine when only one entity was involved; the complication arises in that this is a division-level report so I have to individually resolve the subordinates and their goals before I can aggregate. This is one of two queries I need to tie together using a WITH clause so I can pivot the whole thing and present it in month-by-month fashion. When I try to tie it together like the query below, I get: invalid relational operator.
select ttls.DATE_INDEX, SUM(ttls.LDS) as TTLLDS, SUM(ttls.TONS) as TTLTONS, u.TARGET_LTPH, u.TARGET_MTPH
from UTIL_TARGET_LOADERS u,
(select DATE_INDEX, VEH_LOC, SUM(LDS) as LDS, SUM(WT) as TONS from
(select c.DATE_INDEX, c.VEH_LOC, COUNT(j.LOAD_JOB_ID) as LDS,
CASE WHEN SUM(w.SPOT_WEIGHT) = 0 THEN SUM(j.MAN_SPOT_WT)
ELSE SUM(w.SPOT_WEIGHT)
END as WT
from TC c, TC_LOAD_JOBS j, LOAD_RATES r, SPOT_WEIGHTS w
where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
and c.DATE_INDEX = w.DATE_INDEX and j.LOAD_RATE_ID = w.LOAD_RATE_ID
and c.VEH_LOC in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
group by c.DATE_INDEX, c.VEH_LOC
union
select c.DATE_INDEX, c.VEH_LOC, COUNT(j.JOB_ID) as LDS,
DECODE(SUM(j.AVG_SPOT_WEIGHT),0,SUM(r.BID_TONS),SUM(j.AVG_SPOT_WEIGHT)) as WT
from TC_3RDPARTY c, TC_3RDPARTY_JOBS j, LOAD_RATES r
where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
and j.FACTORY_ID in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
group by c.DATE_INDEX, c.VEH_LOC)
group by DATE_INDEX, VEH_LOC) ttls
where ttls.DATE_INDEX beween u.START_DATE and NVL(u.END_DATE,sysdate)
and ttls.VEH_LOC = u.ORG_ID
group by ttls.DATE_INDEXI know this is a nested mess, as it has to grab the production from two tables for a range of VEH_LOC values and sum and aggregate by day and VEH_LOC, then I have to try and match that to the targets based on VEH_LOC and day. My final query is to aggregate the whole mess of sums and averages by month.
I'd appreciate it if someone can point me in the right direction.Figured it out.
select ttl.DATE_INDEX, SUM(ttl.LDS) as TTLLDS, SUM(ttl.TONS) as TTLTONS,
AVG((u.MACH_TPH_D+u.MACH_TPH_N)/2) as MTPH_TGT,
AVG((u.LABOR_TPH_D+u.LABOR_TPH_N)/2) as LTPH_TGT
from
(select DATE_INDEX, VEH_LOC, SUM(LDS) as LDS, SUM(WT) as TONS from
(select c.DATE_INDEX, c.VEH_LOC, COUNT(j.LOAD_JOB_ID) as LDS,
CASE WHEN SUM(w.SPOT_WEIGHT) = 0 THEN SUM(j.MAN_SPOT_WT)
ELSE SUM(w.SPOT_WEIGHT)
END as WT
from TC c, TC_LOAD_JOBS j, LOAD_RATES r, SPOT_WEIGHTS w
where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
and c.DATE_INDEX = w.DATE_INDEX and j.LOAD_RATE_ID = w.LOAD_RATE_ID
and c.VEH_LOC in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
group by c.DATE_INDEX, c.VEH_LOC
union
select c.DATE_INDEX, c.VEH_LOC, COUNT(j.JOB_ID) as LDS,
DECODE(SUM(j.AVG_SPOT_WEIGHT),0,SUM(r.BID_TONS),SUM(j.AVG_SPOT_WEIGHT)) as WT
from TC_3RDPARTY c, TC_3RDPARTY_JOBS j, LOAD_RATES r
where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID
and c.DATE_INDEX between to_date('08/01/2010','MM/DD/YYYY') and to_date('07/31/2011','MM/DD/YYYY')
and j.FACTORY_ID in (select ORG_ID from ORG_ENTITIES where MNG_ORG_ID = 200)
group by c.DATE_INDEX, c.VEH_LOC)
group by DATE_INDEX, VEH_LOC) ttl, UTIL_TARGET_LOADERS u
where u.ORG_ID = ttl.VEH_LOC
and ttl.DATE_INDEX between u.START_DATE and NVL(U.END_DATE,sysdate)
group by ttl.DATE_INDEX, (u.LABOR_TPH_D+u.LABOR_TPH_N)/2 -
Hi All,
We have a native SQL query accessing Oracle database(given below).
Can anyone please let me know what this query is about and how can we fine tune the query?
SELECT O.OBJECT_NAME ,
H.SID,
HS.MACHINE,
HS.PROCESS,
W.SID,
WS.MACHINE,
WS.PROCESS,
H.CTIME,
W.CTIME,
WS.ROW_WAIT_OBJ#,
WS.ROW_WAIT_FILE#,
WS.ROW_WAIT_BLOCK#,
WS.ROW_WAIT_ROW#,
HP.SPID,
WP.SPID
FROM V$LOCK H, V$LOCK W, V$LOCK I, V$LOCK I2, ALL_OBJECTS O,
V$SESSION HS, V$SESSION WS, V$PROCESS HP, V$PROCESS WP
WHERE H.ID1 = W.ID1
AND H.SID <> W.SID
AND H.TYPE IN ('TX','DL')
AND H.REQUEST = 0
AND H.SID = I.SID
AND I.TYPE = 'TM'
AND I.ID1 = O.OBJECT_ID
AND I.ID1 = I2.ID1
AND W.SID = I2.SID
AND I2.TYPE = 'TM'
AND H.SID = HS.SID
AND W.SID = WS.SID
AND HS.PADDR = HP.ADDR
AND WS.PADDR = WP.ADDR
INTO :EXCL_LOCK_WAITERS-OBJ_NAME ,
:EXCL_LOCK_WAITERS-HOLDER_SID ,
:EXCL_LOCK_WAITERS-H_HOSTNAME ,
:EXCL_LOCK_WAITERS-HOLDER_PID ,
:HOLDER_PID ,
:EXCL_LOCK_WAITERS-WAITER_SID ,
:EXCL_LOCK_WAITERS-W_HOSTNAME ,
:EXCL_LOCK_WAITERS-WAITER_PID ,
:WAITER_PID ,
:EXCL_LOCK_WAITERS-HELD_SINCE ,
:EXCL_LOCK_WAITERS-WAITSSINCE,
:ROW_WAIT_OBJ,
:ROW_WAIT_FILE,
:ROW_WAIT_BLOCK,
:ROW_WAIT_ROW,
:H_PROCESS,
:W_PROCESS
ENDEXEC
Thanks in advance.
Neethu MohanHi Neethu,
It gives you an overwiew of blocking Oracle sessions.
1. In general, the SQL checks Oracle sessions (SID's) that were requirering a DML lock ('TM') and now holding row locks (TX) to prevent destructive interference of simultaneous conflicting DML or DDL operations. DML statements automatically acquire both table-level locks and row-level locks ('TX') => holders
It joins these with the sessions that are waiting of releasing the lock by the holders => waiters.
2. it retrieves the detail information wich Oracle process , the object (table) , it's row , block and file
are affected by the locks.
3. Normally, the locks are only hold for a short period of time. If you have blocking sessions it may be of a log running task (i.e. mass data update of a table) ; but it could also be a application bug due to improper handling of concurrent updates of the same object.
4. Tuning
V$tables are expensive to query: Why?
v$ tables are generally Oracle memory structures.
v$ tables are not read consistent.
v$ tables require latches to access -- cannot modify and read memory at the same
time.
heavy access to v$ tables like this may cause some serious heavy duty contention.
Especially if you self join V$lock several times.
So the best would be to save the contents of V$LOCK in some table:
Create table mylocks as select * from v$lock;
Use that table for self-joining and joins to the other tables.
You can also CTAS the other v$ tables to bypass the performance bottleneck while retrieving
v$ directly.
You can empty or drop the created tables any time for new data.
Because you want to investigate only lock hold for a longert time to copy the v$ memory structures into
physical tables is not a disadvantage. You certainly will wait longer on finishing your query
instead of copy them into the tables.
Hope this helped
yk -
Heirarchy query - Need help please!
DB ver: Oracle DB 10g Rel2
I have data as follows
LAST_NAME EMPLOYEE_ID MANAGER_ID
King 100 null
Cambrault 148 100
Bates 172 148
Bloom 169 148
Fox 170 148
Ozer 168 172
Smith 171 172
De Haan 102 169
Hunold 103 169
Austin 105 169
Ernst 104 170
When Cambrault(emp.id:148) logs in he should see the reporting structure as follows
- Cambrault
-- Bates
--- Ozer
--- Smith
-- Bloom
--- De Haan
--- Hunold
--- Austin
-- Fox
--- Ernst
Similerly when Bates(Emp.Id:172) logs in he should see as follows
- Bates
-- Ozer
-- Smith
How to write a query to get output of records as above?
I could write it as follows but getting all the records.
SELECT e1.ename||' works for Supervisor '||e2.ename
FROM emp e1, emp e2
WHERE e1.mgr = e2.empno;
Any help is highly appreciated. Thanks in advance.
movva
Edited by: cmovva on 27-Oct-2011 12:07 PMmaybe this example might help.
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7902 FORD ANALYST 7782 03-Dec-81 3000.00 20
7839 KING PRESIDENT 17-Nov-81 5000.00 10
7698 BLAKE MANAGER 7839 01-May-81 2850.00 30
7782 CLARK MANAGER 7839 09-Jun-81 2450.00 10
7788 SCOTT ANALYST 7782 09-Dec-82 3000.00 20
7844 TURNER SALESMAN 7698 08-Sep-81 1500.00 0.00 30
7876 ADAMS CLERK 7782 12-Jan-83 1100.00 20
7900 JAMES CLERK 7698 03-Dec-81 950.00 30
7934 MILLER CLERK 7782 23-Jan-82 1300.00 10
7945 CINDY SALESMAN 7698 16-Jan-83 1800.00 30
7950 TINA SALESMAN 7698 18-Jan-83 1850.00 30
11 rows selected
SQL>
SQL> select substr(lpad(' ',2*(level-1)) || ename,1,40) employee_name, job, hiredate, sal
2 from emp
3 start with mgr is null
4 connect by prior empno = mgr;
EMPLOYEE_NAME JOB HIREDATE SAL
KING PRESIDENT 17-Nov-81 5000.00
BLAKE MANAGER 01-May-81 2850.00
TURNER SALESMAN 08-Sep-81 1500.00
JAMES CLERK 03-Dec-81 950.00
CINDY SALESMAN 16-Jan-83 1800.00
TINA SALESMAN 18-Jan-83 1850.00
CLARK MANAGER 09-Jun-81 2450.00
SCOTT ANALYST 09-Dec-82 3000.00
ADAMS CLERK 12-Jan-83 1100.00
FORD ANALYST 03-Dec-81 3000.00
MILLER CLERK 23-Jan-82 1300.00
11 rows selected
SQL> using your sample data something like this:
SQL> select *
2 from (select 'King' last_name, 100 employee_id, null manager_id from dual union all
3 select 'Cambrault' last_name, 148 employee_id, 100 manager_id from dual union all
4 select 'Bates' last_name, 172 employee_id, 148 manager_id from dual union all
5 select 'Bloom' last_name, 169 employee_id, 148 manager_id from dual union all
6 select 'Fox' last_name, 170 employee_id, 148 manager_id from dual union all
7 select 'Ozer' last_name, 168 employee_id, 172 manager_id from dual union all
8 select 'Smith' last_name, 171 employee_id, 172 manager_id from dual union all
9 select 'De,Haan' last_name, 102 employee_id, 169 manager_id from dual union all
10 select 'Hunold' last_name, 103 employee_id, 169 manager_id from dual union all
11 select 'Austin' last_name, 105 employee_id, 169 manager_id from dual union all
12 select 'Ernst' last_name, 104 employee_id, 170 manager_id from dual) e;
LAST_NAME EMPLOYEE_ID MANAGER_ID
King 100
Cambrault 148 100
Bates 172 148
Bloom 169 148
Fox 170 148
Ozer 168 172
Smith 171 172
De,Haan 102 169
Hunold 103 169
Austin 105 169
Ernst 104 170
11 rows selected
SQL>
SQL> select substr(lpad(' ',2*(level-1)) || e.last_name,1,40) last_name,
2 e.employee_id,
3 e.manager_id
4 from (select 'King' last_name, 100 employee_id, null manager_id from dual union all
5 select 'Cambrault' last_name, 148 employee_id, 100 manager_id from dual union all
6 select 'Bates' last_name, 172 employee_id, 148 manager_id from dual union all
7 select 'Bloom' last_name, 169 employee_id, 148 manager_id from dual union all
8 select 'Fox' last_name, 170 employee_id, 148 manager_id from dual union all
9 select 'Ozer' last_name, 168 employee_id, 172 manager_id from dual union all
10 select 'Smith' last_name, 171 employee_id, 172 manager_id from dual union all
11 select 'De,Haan' last_name, 102 employee_id, 169 manager_id from dual union all
12 select 'Hunold' last_name, 103 employee_id, 169 manager_id from dual union all
13 select 'Austin' last_name, 105 employee_id, 169 manager_id from dual union all
14 select 'Ernst' last_name, 104 employee_id, 170 manager_id from dual) e
15 start with e.manager_id is null
16 connect by prior e.employee_id = e.manager_id;
LAST_NAME EMPLOYEE_ID MANAGER_ID
King 100
Cambrault 148 100
Bloom 169 148
De,Haan 102 169
Hunold 103 169
Austin 105 169
Fox 170 148
Ernst 104 170
Bates 172 148
Ozer 168 172
Smith 171 172
11 rows selected
SQL> -
Almost there; keyword search query need help
I will want to eventually add more columns to search but
wanted to get it working with story only for now. I think I am very
close. I have a very simple form with a textfield and submit
button. the search field has a binding Request.search variable
assigned to it. My query works in the Recordset Dialog box, can
enter a test value in simple mode and it works. I entered
construction and get three stories containing construction.
Main problem is that no matter what I search when testing
through my browser using my pc's Inetpub/wwwroot I get all news
stories. I can even type in a weird search word like zebra and
still get all records.
here is my simple form code
<form id="form1" name="form1" method="get"
action="keywordjimresults.asp">
<input name="search" type="text" id="search"
value="<%= Request("search") %>" />
<br />
<input type="submit" value="Search" />
</form>
Here is my results page code
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 10
Repeat1__index = 0
rsKeyword_numRows = rsKeyword_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="650" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td><form id="form1" name="form1" method="get"
action="keywordjimresults.asp">
<input name="search" type="text" id="search"
value="<%= Request("search") %>" />
<br />
<input type="submit" value="Search" />
</form> </td>
<td rowspan="6"> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
THANK YOU JimI don't see anything at the bottom.
Suggest that you open the blank file to the size that you want, and the resolution the same as that of the picture.
Bring both of these into view - tile view is good
Drag picture to blank file. Do not drag from the project bin for this purpose
You could also open the picture, go to Select>all, then Edit>copy. This will put it on the clipboard. Then in your destination, go to Edit>paste
Resizing can be done in several ways. The least complicated way, in my opinion, is to use the crop tool, where you can enter the width and height in inches, and the resolution as well. The aspect ratio of the original picture may not conform to what you want. For example, a 4x6" picture has to be cropped in order to arrive at 1x1" - something has to go. -
Hi all,
i have solution i got earlier form this forum.
CREATE TABLE LHEADER
(HDT DATE,
HSR NUMBER,
HCODE VARCHAR2(6),
HAMOUNT NUMBER);
INSERT INTO LHEADER VALUES (TO_DATE('01012009','DD/MM/YYYY'),1,101,5000);
INSERT INTO LHEADER VALUES (TO_DATE('01022009','DD/MM/YYYY'),2,102,3000);
INSERT INTO LHEADER VALUES (TO_DATE('01012009','DD/MM/YYYY'),3,103,6000);
CREATE TABLE DDETAIL
(DDT DATE,
DHSR NUMBER,
DHCODE VARCHAR2(6),
DAMOUNT NUMBER,
D1 NUMBER,
D2 NUMBER,
D3 NUMBER);
INSERT INTO DDETAIL VALUES (TO_DATE('31012009','DD/MM/YYYY'),1,101,1500,NULL,NULL,10);
INSERT INTO DDETAIL VALUES (TO_DATE('31012009','DD/MM/YYYY'),1,101,NULL,20,15,20);
INSERT INTO DDETAIL VALUES (TO_DATE('28022009','DD/MM/YYYY'),1,101,NULL,20,12,20);
INSERT INTO DDETAIL VALUES (TO_DATE('31032009','DD/MM/YYYY'),1,101,NULL,20,16,20);
INSERT INTO DDETAIL VALUES (TO_DATE('30042009','DD/MM/YYYY'),1,101,NULL,20,20,20);
INSERT INTO DDETAIL VALUES (TO_DATE('28022009','DD/MM/YYYY'),2,102,2000,15,NULL,15);
INSERT INTO DDETAIL VALUES (TO_DATE('28022009','DD/MM/YYYY'),2,102,NULL,12,10,15);
INSERT INTO DDETAIL VALUES (TO_DATE('31032009','DD/MM/YYYY'),2,102,NULL,12,15,8);
INSERT INTO DDETAIL VALUES (TO_DATE('30042009','DD/MM/YYYY'),2,102,NULL,12,12,15);
INSERT INTO DDETAIL VALUES (TO_DATE('31012009','DD/MM/YYYY'),3,103,NULL,30,20,25);
INSERT INTO DDETAIL VALUES (TO_DATE('28022009','DD/MM/YYYY'),3,103,NULL,30,20,25);
INSERT INTO DDETAIL VALUES (TO_DATE('31032009','DD/MM/YYYY'),3,103,NULL,30,20,25);
INSERT INTO DDETAIL VALUES (TO_DATE('30042009','DD/MM/YYYY'),3,103,3000,NULL,30,25);
INSERT INTO DDETAIL VALUES (TO_DATE('30042009','DD/MM/YYYY'),3,103,NULL,30,20,25);
SELECT ddt
, dhsr
, dhcode
, NVL ( CASE
WHEN d1 + d2 + d3 IS NULL
THEN LAG (run_tot) OVER ( PARTITION BY dhcode
, dhsr
ORDER BY ddt
END
, amount
) AS amount
, d1
, d2
, d3
, run_tot
FROM (
SELECT d.ddt
, d.dhsr
, d.dhcode
, NVL ( d.damount
, h.hamount
) AS amount
, d.d1
, d.d2
, d.d3
, h.hamount - CASE
WHEN d1 + d2 + d3 IS NULL
THEN NULL
ELSE SUM ( d.d1
+ d.d2
+ d.d3
) OVER ( PARTITION BY d.dhcode
, d.dhsr
ORDER BY d.ddt
END AS run_tot
FROM ddetail d
, lheader h where d.dhcode = h.hcode
AND d.dhsr = h.hsr
ORDER BY ddt
, dhcode
, d1 + d2 + d3 NULLS FIRST
DDT DHSR DHCODE AMOUNT D1 D2 D3 RUN_TOT
31/01/2009 1.000 101 1500.000 10.000
31/01/2009 1.000 101 5000.000 20.000 15.000 20.000 4945.000
31/01/2009 3.000 103 6000.000 30.000 20.000 25.000 5925.000
28/02/2009 1.000 101 5000.000 20.000 12.000 20.000 4893.000
28/02/2009 2.000 102 2000.000 15.000 15.000
28/02/2009 2.000 102 3000.000 12.000 10.000 15.000 2963.000
28/02/2009 3.000 103 6000.000 30.000 20.000 25.000 5850.000
31/03/2009 1.000 101 5000.000 20.000 16.000 20.000 4837.000
31/03/2009 2.000 102 3000.000 12.000 15.000 8.000 2928.000
31/03/2009 3.000 103 6000.000 30.000 20.000 25.000 5775.000
30/04/2009 1.000 101 5000.000 20.000 20.000 20.000 4777.000
30/04/2009 2.000 102 3000.000 12.000 12.000 15.000 2889.000
30/04/2009 3.000 103 5775.000 30.000 25.000
30/04/2009 3.000 103 6000.000 30.000 20.000 25.000 5700.000
14 rows selected.i want to the output to be like this now;
the query should SUM d1,d2 & d3 where RUN_TOT is NULL.
Rows with Null RUN_TOT should not be shown.
DDT DHSR DHCODE AMOUNT D1 D2 D3 RUN_TOT
31/01/2009 1.000 101 5000.000 20.000 15.000 *30.000* 4945.000
31/01/2009 3.000 103 6000.000 30.000 20.000 25.000 5925.000
28/02/2009 1.000 101 5000.000 20.000 12.000 20.000 4893.000
28/02/2009 2.000 102 3000.000 *27.000* 10.000 *30.000* 2963.000
28/02/2009 3.000 103 6000.000 30.000 20.000 25.000 5850.000
31/03/2009 1.000 101 5000.000 20.000 16.000 20.000 4837.000
31/03/2009 2.000 102 3000.000 12.000 15.000 8.000 2928.000
31/03/2009 3.000 103 6000.000 30.000 20.000 25.000 5775.000
30/04/2009 1.000 101 5000.000 20.000 20.000 20.000 4777.000
30/04/2009 2.000 102 3000.000 12.000 12.000 15.000 2889.000
30/04/2009 3.000 103 6000.000 30.000 *50.000 50.000* 5700.000
14 rows selected.Hello Mr. Frank..
I designed a report based on your solution, but when executed with the actual data, with what the user have entered,
the report didn't returned the expected result. Yes, your logic with the earlier data provided by me was correct.
but now the data has appeared in different manner.
i tried to modify your query but didn't exactly succeed.
for this data;
CREATE TABLE LHEADER
(HDT DATE,
HSR NUMBER,
HCODE VARCHAR2(6),
HAMOUNT NUMBER);
INSERT INTO LHEADER VALUES (TO_DATE('10/03/2010','DD/MM/YYYY'),12,1392,48571.1);
INSERT INTO LHEADER VALUES (TO_DATE('16/03/2010','DD/MM/YYYY'),14,1526,40732);
INSERT INTO LHEADER VALUES (TO_DATE('08/01/2010','DD/MM/YYYY'),9,1835,31600);
CREATE TABLE DDETAIL
(DDT DATE,
DHSR NUMBER,
DHCODE VARCHAR2(6),
DAMOUNT NUMBER,
D1 NUMBER,
D2 NUMBER,
D3 NUMBER);
INSERT INTO DDETAIL VALUES (TO_DATE('01/10/2009','DD/MM/YYYY'),12,1392,37103,NULL,12.986,217.434);
INSERT INTO DDETAIL VALUES (TO_DATE('01/11/2009','DD/MM/YYYY'),12,1392,37103,NULL,12.986,210.420);
INSERT INTO DDETAIL VALUES (TO_DATE('01/09/2009','DD/MM/YYYY'),12,1392,37103,NULL,12.986,210.420);
INSERT INTO DDETAIL VALUES (TO_DATE('01/12/2009','DD/MM/YYYY'),12,1392,2470,NULL,0,2.335);
INSERT INTO DDETAIL VALUES (TO_DATE('01/12/2009','DD/MM/YYYY'),12,1392,39573,NULL,13.851,231.909);
INSERT INTO DDETAIL VALUES (TO_DATE('01/01/2010','DD/MM/YYYY'),12,1392,39573,NULL,13.851,231.909);
INSERT INTO DDETAIL VALUES (TO_DATE('01/02/2010','DD/MM/YYYY'),12,1392,39573,NULL,13.850,209.466);
INSERT INTO DDETAIL VALUES (TO_DATE('01/02/2010','DD/MM/YYYY'),12,1392,4489.7,NULL,5.836,23.765);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2010','DD/MM/YYYY'),12,1392,4489.7,NULL,2.918,26.311);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2010','DD/MM/YYYY'),12,1392,39573,0,13.855,231.909);
INSERT INTO DDETAIL VALUES (TO_DATE('01/12/2008','DD/MM/YYYY'),14,1526,11620,NULL,0,50.046);
INSERT INTO DDETAIL VALUES (TO_DATE('01/01/2009','DD/MM/YYYY'),14,1526,11620,NULL,4.066,64.642);
INSERT INTO DDETAIL VALUES (TO_DATE('01/02/2009','DD/MM/YYYY'),14,1526,11620,NULL,4.066,58.387);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2009','DD/MM/YYYY'),14,1526,11620,NULL,4.066,64.642);
INSERT INTO DDETAIL VALUES (TO_DATE('01/04/2009','DD/MM/YYYY'),14,1526,19220,NULL,6.726,103.472);
INSERT INTO DDETAIL VALUES (TO_DATE('01/05/2009','DD/MM/YYYY'),14,1526,19220,NULL,6.726,106.921);
INSERT INTO DDETAIL VALUES (TO_DATE('01/05/2009','DD/MM/YYYY'),14,1526,7600,NULL,NULL,17.73);
INSERT INTO DDETAIL VALUES (TO_DATE('01/06/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.386,144.387);
INSERT INTO DDETAIL VALUES (TO_DATE('01/07/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.386,149.200);
INSERT INTO DDETAIL VALUES (TO_DATE('01/08/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,48.129);
INSERT INTO DDETAIL VALUES (TO_DATE('01/08/2009','DD/MM/YYYY'),14,1526,26820,NULL,NULL,106.472);
INSERT INTO DDETAIL VALUES (TO_DATE('01/09/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,152.102);
INSERT INTO DDETAIL VALUES (TO_DATE('01/10/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,157.173);
INSERT INTO DDETAIL VALUES (TO_DATE('01/11/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,152.102);
INSERT INTO DDETAIL VALUES (TO_DATE('01/12/2009','DD/MM/YYYY'),14,1526,26820,NULL,9.387,157.173);
INSERT INTO DDETAIL VALUES (TO_DATE('01/01/2010','DD/MM/YYYY'),14,1526,5700,NULL,NULL,8.620);
INSERT INTO DDETAIL VALUES (TO_DATE('01/01/2010','DD/MM/YYYY'),14,1526,32520,NULL,11.382,190.576);
INSERT INTO DDETAIL VALUES (TO_DATE('01/02/2010','DD/MM/YYYY'),14,1526,32520,NULL,11.382,172.133);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2010','DD/MM/YYYY'),14,1526,37745,NULL,13.21,221.196);
INSERT INTO DDETAIL VALUES (TO_DATE('01/03/2010','DD/MM/YYYY'),14,1526,5225,NULL,NULL,4.939);
INSERT INTO DDETAIL VALUES (TO_DATE('04/01/2010','DD/MM/YYYY'),9,1835,31600,131.667,11.06,185.185);
INSERT INTO DDETAIL VALUES (TO_DATE('05/02/2010','DD/MM/YYYY'),9,1835,31468.333,131.667,11.014,166.567);
INSERT INTO DDETAIL VALUES (TO_DATE('08/03/2010','DD/MM/YYYY'),9,1835,31336.666,131.667,10.968,183.641);
INSERT INTO DDETAIL VALUES (TO_DATE('10/04/2010','DD/MM/YYYY'),9,1835,31204.999,131.667,10.922,176.971);
i modified your query like this;
SELECT ddt
, dhsr
, dhcode
, amount
, d1
, d2
, d3
, run_tot
FROM (
SELECT ddt
, dhsr
, dhcode
, NVL ( CASE
WHEN NVL(d1 + d2 + d3,0) = 0
THEN LAG (run_tot) OVER ( PARTITION BY dhcode,to_char(ddt,'yyyymm')
ORDER BY ddt
END
, amount
) AS amount
, SUM (NVL(d1,0)) OVER ( PARTITION BY dhcode,to_char(ddt,'yyyymm')
, a_cnt
) AS d1
, SUM (NVL(d2,0)) OVER ( PARTITION BY dhcode,to_char(ddt,'yyyymm')
, a_cnt
) AS d2
, SUM (NVL(d3,0)) OVER ( PARTITION BY dhcode,to_char(ddt,'yyyymm')
, a_cnt
) AS d3
, run_tot
FROM (
SELECT d.ddt
, d.dhsr
, d.dhcode
, NVL ( d.damount
, h.hamount
) AS amount
, d.d1
, d.d2
, d.d3
, h.hamount - CASE
WHEN NVL(d1 + d2 + d3,0) = 0
THEN NULL
ELSE SUM ( NVL(d.d1
+ d.d2
+ d.d3,0)
) OVER ( PARTITION BY dhcode,to_char(ddt,'yyyymm')
ORDER BY d.ddt
END AS run_tot
, COUNT (d1 + d2 + d3) OVER ( PARTITION BY dhcode,to_char(ddt,'yyyymm')
ORDER BY d.ddt DESC
) AS a_cnt
FROM ddetail d
, lheader h where d.dhcode = h.hcode
AND d.dhsr = h.hsr
--WHERE run_tot IS NOT NULL
WHERE to_char(ddt,'yyyymm') = '201003'
ORDER BY ddt
, dhcode
, d1 + d2 + d3
i got this output;
DDT DHSR DHCODE AMOUNT D1 D2 D3 RUN_TOT
01/03/2010 12 1392 4489.7 0 16.773 258.22
01/03/2010 12 1392 39573 0 16.773 258.22 48325.336
01/03/2010 14 1526 37745 0 13.21 226.135
01/03/2010 14 1526 5225 0 13.21 226.135
08/03/2010 9 1835 31336.666 131.667 10.968 183.641 31273.724
but the expected result should be like this;
DDT DHSR DHCODE AMOUNT D1 D2 D3 RUN_TOT
01/03/2010 12 1392 39573 0 16.773 258.220 39573.000
01/03/2010 14 1526 37745 13.210 226.135 37745.000
08/03/2010 9 1835 31336.666 131.667 10.968 183.641 31204.999
and when i change the last condition part...to
WHERE run_tot IS NOT NULL
AND to_char(ddt,'yyyymm') = '201003'
ORDER BY ddt
, dhcode
, d1 + d2 + d3 ...
DDT DHSR DHCODE AMOUNT D1 D2 D3 RUN_TOT
01/03/2010 12 1392 39573 0 16.773 258.22 48325.336
08/03/2010 9 1835 31336.666 131.667 10.968 183.641 31273.724
1. The row for dhcode 1526 does not appear and
2. The runtot for 1835 gets wrongly calculated (it should be 31336.666-131.667=31204.999)Please suggest .
TYVM. -
Access permission query - need help
Hi ,
I want to produce the following scenario:-
1. I created a new portal user called neerajs/pass123.
2. Created a new page group.
3. Created a new page into the page group created in step 2.
4. created a new tab inside the page created in step 3.
5. added a portlet into the tab created in step 4.
Now i want that when user neerajs will log in he must see only the portlet added in step 5.
The user neerajs will find only the links Home,Help and Logout.
I have done the following:
1. Grant access to user neerajs for the page group created in step 2.
2. default page group for user neerajs is set to the one created in step2.
Could any one suggest some way to do this or suggest the documentation which i can refer.
Thnx
<Neeraj Sidhaye/>Hi ,
Thanks for you reply.
I will try this out and will let you know the results.
Are you talking about "setting default home page" for the user ,in your last line of reply ?
I think , this is the case when user clicks on Home link then this default page will be rendered. Am i right ?
Is there any docs which can tell all about the Access Privileges and also tells about how to play with Role Based Security in Oracle Portal Server ?
Thanks Again
<Neeraj Sidhaye/>
Try_Catch_Finally AT YAHOO DOT COM
http://ExtremePortal.blog.co.uk -
Prg
CASE SY-UCOMM .
WHEN 'SAVE'.
REFRESH IT_CURR.
LOOP AT G_TC_VALUE_ITAB INTO G_TC_VALUE_WA .
MOVE-CORRESPONDING G_TC_VALUE_WA TO IT_CURR .
IT_CURR-POSNR = GV_POSNR .
IT_CURR-VBELN = GV_VBELN .
APPEND IT_CURR .
ENDLOOP .
DELETE IT_CURR WHERE ZWMENG_CPD EQ 0.
LOOP AT IT_CURR .
TOTAL = IT_CURR-ZWMENG_CPD + TOTAL.
ENDLOOP.
IF TOTAL > GV_KWMENG.
IF SY-SUBRC EQ 0.
MESSAGE ID 'Z1' TYPE 'I' NUMBER '222' WITH 'Order Qty > CPD Qty'.
LEAVE TO SCREEN 100.
ENDIF.
ENDIF.
CLEAR G_TC_VALUE_COPIED.
LEAVE TO SCREEN 0 .
WHEN 'CANC'.
CLEAR G_TC_VALUE_COPIED.
LEAVE TO SCREEN 0 .
ENDCASE .
1)it_curr which contain the dynamical inputted values
eg 1000
1000
total 2000 over
if i input 500 and 1000 after saving button on the top
now total contents is
1000
1000<----
after this delete val
500 <--- delete all consc val
1000 <---
2)GV_KWMENG contain 2000 value
3) from it_curr i calculate
TOTAL = IT_CURR-ZWMENG_CPD + TOTAL.
4)
againing loop with condition total > than gv_kwmeng
5) delete the concecutive value after condition is trueIf I use following query
SELECT DISTINCT STAGE_1_MG_CLIENT.CLIENT_ID, STAGE_1_MG_CLIENT.BIRTH_DT, STAGE_1_MG_CLIENT.ETHNIC_CD, STAGE_1_MG_CLIENT.GENDER_CD, STAGE_1_MG_CLIENT.MEDICARE_NUMBER, STAGE_1_MG_CLIENT.MEDICARE_YN, STAGE_1_MG_CLIENT.ALIAS_YN, ltrim(rtrim(STAGE_1_MG_CLIENT.SAVERR_NAME)), STAGE_1_MG_CLIENT.SSN, STAGE_1_MG_CLIENT.TERMINATION_CD, STAGE_1_MG_CLIENT.TPL, STAGE_1_MG_ENROLLMENT.CLIENT_ID, STAGE_1_MG_ENROLLMENT.SERVICE_GROUP_CD, STAGE_1_SAVERR.CLIENT_ID, STAGE_1_SAVERR.SSN, STAGE_1_SAVERR.STAT_2, STAGE_1_SAVERR.STAT_3, STAGE_1_SAVERR.STAT_4, STAGE_1_SAVERR.STAT_5, STAGE_1_SAVERR.STAT_6, STAGE_1_SAVERR.MEDICAID_BENEFITS_close_DT, STAGE_1_SAVERR.ACTION FROM STAGE_1_SAVERR, STAGE_1_MG_ENROLLMENT, STAGE_1_MG_CLIENT where STAGE_1_MG_CLIENT.CLIENT_ID = STAGE_1_SAVERR.CLIENT_ID (+) and STAGE_1_MG_CLIENT.CLIENT_ID = STAGE_1_MG_ENROLLMENT.CLIENT_ID (+) and STAGE_1_MG_ENROLLMENT.SERVICE_GROUP_CD(+) in ('2','3','12','13','14','15','16','17','18')
I get the following error message
Error at Command Line:1 Column:892
Error report:
SQL Error: ORA-01719: outer join operator (+) not allowed in operand of OR or IN
Thanks,
Jay -
Need Help in Splitting a String Using SQL QUERY
Hi,
I need help in splitting a string using a SQL Query:
String IS:
AFTER PAINT.ACOUSTICAL.1..9'' MEMBRAIN'I would like to seperate this string into multiple lines using the delimeter .(dot)
Sample Output should look like:
SNO STRING
1 AFTER PAINT
2 ACOUSTICAL
3 1
4
5 9" MEMBRAIN
{code}
FYI i am using Oracle 9.2There's this as well:
with x as ( --generating sample data:
select 'AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN' str from dual union all
select 'BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN' str from dual)
select str,
row_number() over (partition by str order by rownum) s_no,
cast(dbms_xmlgen.convert(t.column_value.extract('//text()').getstringval(),1) as varchar2(100)) res
from x,
table(xmlsequence(xmltype('<x><x>' || replace(str,'.','</x><x>') || '</x></x>').extract('//x/*'))) t;
STR S_NO RES
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 1 AFTER PAINT
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 2 ACOUSTICAL
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 3 1
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 4
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 5 9" MEMBRAIN
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 1 BEFORE PAINT
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 2 ELECTRIC
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 3 2
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 4
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 5 45 caliber MEMBRAIN
{code} -
Need help with conditional query
guys this is just an extension of this post that Frank was helping me with. im reposting because my requirements have changes slightly and im having a hell of a time trying to modify the query.
here is the previous post.
need help with query that can look data back please help.
CREATE TABLE "FGL"
"FGL_GRNT_CODE" VARCHAR2(60),
"FGL_FUND_CODE" VARCHAR2(60),
"FGL_ACCT_CODE" VARCHAR2(60),
"FGL_ORGN_CODE" VARCHAR2(60),
"FGL_PROG_CODE" VARCHAR2(60),
"FGL_GRNT_YEAR" VARCHAR2(60),
"FGL_PERIOD" VARCHAR2(60),
"FGL_BUDGET" VARCHAR2(60)
)data
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','00','400');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','100');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','0');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','1','400');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('360055','360055','7200','4730','02','10','1','400');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('360055','360055','7600','4730','02','10','1','400');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','14','100');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','2','100');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','11','2','600');
I need to find the greatest grant year for the grant by a period parameter.
once i find the greatest year i need to check the value of period 14 for that grant for the previous year and add it to the budget amount for that grant. however if their is an entry in the greatest year for period 00 then i need to ignore the period 14 of previous year and do this calculation current period +(current period - greatest year 00)
hope that makes sense so in other words with the new data above. if i was querying period two of grant year 11. i would end up with $800
because the greatest year is 11 it contains a period 0 with amount of $400 so my total should be
period 2 amount $ 600
period 0 amount $ 400 - period 2 amount of $600 = 200
600+200 = $800
if i query period 1 of grant 360055 i would just end up with 800 of grnt year 10.
i have tried to modify that query you supplied to me with no luck. I have tried for several day but im embarrased to say i just can get it to do what im trying to do .
can you please help me out.
here is the query supplied by frank kulash who gracefully put this together for me.
WITH got_greatest_year AS
SELECT fgl.* -- or whatever columns are needed
, MAX ( CASE
WHEN fgl_period = :given_period
THEN fgl_grnt_year
END
) OVER () AS greatest_year
FROM fgl
SELECT SUM (fgl_budget) AS total_budget -- or SELECT *
FROM got_greatest_year
WHERE ( fgl_grnt_year = greatest_year
AND fgl_period = :given_period
OR ( fgl_grnt_year = greatest_year - 1
AND fgl_period = 14
;MiguelHi, Miguel,
Are you waying that, when the greatest year that has :given_period also has period='00' (or '0', or whatever you want to use), then you want to double the budget from the given_period (as well as subtract the budget from the '00', and not count the pevious year's '14')? If so, add another condition to the CASE statement which decides what you're SUMming:
WITH got_greatest_year AS
SELECT TO_NUMBER (fgl_grnt_year) AS grnt_year
, fgl_period
, TO_NUMBER (fgl_budget) AS budget
, MAX ( CASE
WHEN fgl_period = :given_period
THEN TO_NUMBER (fgl_grnt_year)
END
) OVER () AS greatest_year
FROM fgl
, got_cnt_00 AS
SELECT grnt_year
, fgl_period
, budget
, greatest_year
, COUNT ( CASE
WHEN grnt_year = greatest_year
AND fgl_period = '00'
THEN 1
END
) OVER () AS cnt_00
FROM got_greatest_year
SELECT SUM ( CASE
WHEN grnt_year = greatest_year -- New
AND fgl_period = :given_period -- New
AND cnt_00 > 0 THEN budget * 2 -- New
WHEN grnt_year = greatest_year
AND fgl_period = :given_period THEN budget
WHEN grnt_year = greatest_year
AND fgl_period = '00' THEN -budget
WHEN grnt_year = greatest_year - 1
AND fgl_period = '14'
AND cnt_00 = 0 THEN budget
END
) AS total_budget
FROM got_cnt_00
;You'll notice this is the same as the previous query I posted, except for 3 lines maked "New". -
Hi,
Good day everyone! I need help writing a query. I have this table with the following data in them...
ACCT_CODE FSYR YTD_AMT
A123 11 100
A456 11 200
A123 10 50
A456 10 100I want the output to look like this:
ACCT_CODE CURRENT_YEAR(11) PRIOR_YEAR(10)
A123 100 50
A456 200 100The user will input the fiscal year and based on that input, I want to get the prior year value as well.
Thank you for all your help!!
Edited by: user5737516 on Jun 29, 2011 6:48 AM
Edited by: user5737516 on Jun 29, 2011 6:50 AMuser5737516 wrote:
Hi,
Good day everyone! I need help writing a query. I have this table with the following data in them...
ACCT_CODE FSYR YTD_AMT
A123 11 100
A456 11 200
A123 10 50
A456 10 100
I want the output to look like this:
ACCT_CODE CURRENT_YEAR PRIOR_YEAR
A123 100 50
A456 200 100
The user will input the fiscal year and based on that input, I want to get the prior year value as well.
Thank you for all your help!!what is prior year? -
NEED HELP IN REDUCING THE LENGTH OF QUERY WHICH IS ATTACHED IN A FILE PL_SQ
Hi Everyone,
THANKS FOR POSTING THE REPLIES FOR MY LAST THREAD. THAT REALLY HELPED. I CAME BACK AGAIN BECAUSE I NEED HELP FROM THIS FORUM IN REDUING THE LENGTH OF MY QUERY WHICH I HAD GIVEN BELOW. i DIDN'T HAD THE CHOICE OF ATTACHING A FILE OF MY DATA HERE.ITS VERY HUGE DATA SO I AM NOT ABLE TO PROVIDE ATLEAST SAMPLE DATA BECAUSE THE COLUMNS ARE OVERLAPPING IF I AM PASTING THE DATA HERE. I HOPE IT WILL BE UNDERSTANDABLE. THE QUERY WHICH I WROTE IS TOO LONG AND TAKING HOURS TOGETHER TO RUN AND DISPLAY RESULT. IT WOULD BE A GREAT FAVOUR TO ME IF ANYONE CAN REDUCE THE LINES IN MY QUERY AND MAKE IT RUN FAST....PLEASE I WAS NOT KNOWING THE WAY HOW TO MAKE IT SHORT. IT HAS MANY LOGICS IN IT... :? PLEASE SUGGEST ME IF THERE IS ANY OPTION FOR ATTACHING A FILE SO THAT I CAN SEND MY SAMPLE DATA...
select pt.product code,
pt.product status,
pt.store code,
pt.store status,
pr.scheduled date,
pr.actual date,
pl.scheduled date,
pl.actual date,
ps.scheduled date,
ps.actual date,
fo.scheduled date,
fo.actual date,
fb.scheduled date,
fb.actual date,
fod.scheduled date,
fod.actual date,
lo.scheduled date,
lo.actual date,
lom.scheduled date,
lom.actual date,
lod.scheduled date,
lod.actual date,
/*pr*/
case
WHEN pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' OR
pt.store status = 'Active' THEN
NVL2(pr.scheduled date,
cast(pr.scheduled date AS nvarchar2(30)),
'Null')
when pt.store status = 'Planned' THEN
NVL2(pr.scheduled date,
cast(pr.scheduled date AS nvarchar2(30)),
'Null')
end as DER_pr_SHC,
case
when pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' THEN
NVL2(pr.actual date,
cast(pr.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
pr.scheduled date is null THEN
NVL2(pr.actual date,
cast(pr.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
pr.scheduled date < CURRENT_DATE THEN
NVL2(pr.actual date,
cast(pr.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
pr.scheduled date >= CURRENT_DATE THEN
NVL2(pr.actual date,
cast(pr.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'Planned' and
pr.scheduled date is null THEN
NVL2(pr.actual date,
cast(pr.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'Planned' and
pr.scheduled date < CURRENT_DATE THEN
NVL2(pr.actual date,
cast(pr.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Planned' and
pr.scheduled date >= CURRENT_DATE THEN
NVL2(pr.actual date,
cast(pr.actual date AS nvarchar2(30)),
'N/A')
end as DER_pr_ACT,
/*pl*/
case
WHEN pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' OR
pt.store status = 'Active' THEN
NVL2(pl.scheduled date,
cast(pl.scheduled date AS nvarchar2(30)),
'Null')
when pt.store status = 'Planned' THEN
NVL2(pl.scheduled date,
cast(pl.scheduled date AS nvarchar2(30)),
'Null')
end as DER_pl_SHC,
case
when pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' THEN
NVL2(pl.actual date,
cast(pl.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
pl.scheduled date is null THEN
NVL2(pl.actual date,
cast(pl.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
pl.scheduled date < CURRENT_DATE THEN
NVL2(pl.actual date,
cast(pl.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
pl.scheduled date >= CURRENT_DATE THEN
NVL2(pl.actual date,
cast(pl.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'Planned' and
pl.scheduled date is null THEN
NVL2(pl.actual date,
cast(pl.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'Planned' and
pl.scheduled date < CURRENT_DATE THEN
NVL2(pl.actual date,
cast(pl.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Planned' and
pl.scheduled date >= CURRENT_DATE THEN
NVL2(pl.actual date,
cast(pl.actual date AS nvarchar2(30)),
'N/A')
end as DER_pl_ACT,
/*ps*/
case
WHEN pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' OR
pt.store status = 'Active' THEN
NVL2(ps.scheduled date,
cast(ps.scheduled date AS nvarchar2(30)),
'Null')
when pt.store status = 'planned' THEN
NVL2(ps.scheduled date,
cast(ps.scheduled date AS nvarchar2(30)),
'Null')
end as DER_ps_SHC,
case
when pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' THEN
NVL2(ps.actual date,
cast(ps.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
ps.scheduled date is null THEN
NVL2(ps.actual date,
cast(ps.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
ps.scheduled date < CURRENT_DATE THEN
NVL2(ps.actual date,
cast(ps.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
ps.scheduled date >= CURRENT_DATE THEN
NVL2(ps.actual date,
cast(ps.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
ps.scheduled date is null THEN
NVL2(ps.actual date,
cast(ps.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
ps.scheduled date < CURRENT_DATE THEN
NVL2(ps.actual date,
cast(ps.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'planned' and
ps.scheduled date >= CURRENT_DATE THEN
NVL2(ps.actual date,
cast(ps.actual date AS nvarchar2(30)),
'N/A')
end as DER_ps_ACT,
/*fo*/
case
WHEN pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' OR
pt.store status = 'Active' THEN
NVL2(fo.scheduled date,
cast(fo.scheduled date AS nvarchar2(30)),
'Null')
when pt.store status = 'planned' THEN
NVL2(fo.scheduled date,
cast(fo.scheduled date AS nvarchar2(30)),
'Null')
end as DER_fo_SHC,
case
when pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' THEN
NVL2(fo.actual date,
cast(fo.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
fo.scheduled date is null THEN
NVL2(fo.actual date,
cast(fo.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
fo.scheduled date < CURRENT_DATE THEN
NVL2(fo.actual date,
cast(fo.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
fo.scheduled date >= CURRENT_DATE THEN
NVL2(fo.actual date,
cast(fo.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
fo.scheduled date is null THEN
NVL2(fo.actual date,
cast(fo.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
fo.scheduled date < CURRENT_DATE THEN
NVL2(fo.actual date,
cast(fo.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'planned' and
fo.scheduled date >= CURRENT_DATE THEN
NVL2(fo.actual date,
cast(fo.actual date AS nvarchar2(30)),
'N/A')
end as DER_fo_ACT,
/*fb*/
case
WHEN pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' OR
pt.store status = 'Active' THEN
NVL2(fb.scheduled date,
cast(fb.scheduled date AS nvarchar2(30)),
'Null')
when pt.store status = 'planned' THEN
NVL2(fb.scheduled date,
cast(fb.scheduled date AS nvarchar2(30)),
'Null')
end as DER_fb_SHC,
case
when pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' THEN
NVL2(fb.actual date,
cast(fb.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
fb.scheduled date is null THEN
NVL2(fb.actual date,
cast(fb.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
fb.scheduled date < CURRENT_DATE THEN
NVL2(fb.actual date,
cast(fb.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
fb.scheduled date >= CURRENT_DATE THEN
NVL2(fb.actual date,
cast(fb.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
fb.scheduled date is null THEN
NVL2(fb.actual date,
cast(fb.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
fb.scheduled date < CURRENT_DATE THEN
NVL2(fb.actual date,
cast(fb.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'planned' and
fb.scheduled date >= CURRENT_DATE THEN
NVL2(fb.actual date,
cast(fb.actual date AS nvarchar2(30)),
'N/A')
end as DER_fb_ACT,
/*fod*/
case
WHEN pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Compldeted' OR
pt.store status = 'Active' THEN
NVL2(fod.scheduled date,
cast(fod.scheduled date AS nvarchar2(30)),
'Null')
when pt.store status = 'pldanned' THEN
NVL2(fod.scheduled date,
cast(fod.scheduled date AS nvarchar2(30)),
'Null')
end as DER_fod_SHC,
case
when pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' THEN
NVL2(fod.actual date,
cast(fod.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
fod.scheduled date is null THEN
NVL2(fod.actual date,
cast(fod.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
fod.scheduled date < CURRENT_DATE THEN
NVL2(fod.actual date,
cast(fod.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
fod.scheduled date >= CURRENT_DATE THEN
NVL2(fod.actual date,
cast(fod.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
fod.scheduled date is null THEN
NVL2(fod.actual date,
cast(fod.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
fod.scheduled date < CURRENT_DATE THEN
NVL2(fod.actual date,
cast(fod.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'planned' and
fod.scheduled date >= CURRENT_DATE THEN
NVL2(fod.actual date,
cast(fod.actual date AS nvarchar2(30)),
'N/A')
end as DER_fod_ACT,
/*lo*/
case
WHEN pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' OR
pt.store status = 'Active' THEN
NVL2(lo.scheduled date,
cast(lo.scheduled date AS nvarchar2(30)),
'Null')
when pt.store status = 'planned' THEN
NVL2(lo.scheduled date,
cast(lo.scheduled date AS nvarchar2(30)),
'Null')
end as DER_lo_SHC,
case
when pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' THEN
NVL2(lo.actual date,
cast(lo.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
lo.scheduled date is null THEN
NVL2(lo.actual date,
cast(lo.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
lo.scheduled date < CURRENT_DATE THEN
NVL2(lo.actual date,
cast(lo.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
lo.scheduled date >= CURRENT_DATE THEN
NVL2(lo.actual date,
cast(lo.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
lo.scheduled date is null THEN
NVL2(lo.actual date,
cast(lo.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
lo.scheduled date < CURRENT_DATE THEN
NVL2(lo.actual date,
cast(lo.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'planned' and
lo.scheduled date >= CURRENT_DATE THEN
NVL2(lo.actual date,
cast(lo.actual date AS nvarchar2(30)),
'N/A')
end as DER_lo_ACT,
/*lom*/
case
WHEN pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' OR
pt.store status = 'Active' THEN
NVL2(lom.scheduled date,
cast(lom.scheduled date AS nvarchar2(30)),
'Null')
when pt.store status = 'planned' THEN
NVL2(lom.scheduled date,
cast(lom.scheduled date AS nvarchar2(30)),
'Null')
end as DER_lom_SHC,
case
when pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' THEN
NVL2(lom.actual date,
cast(lom.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
lom.scheduled date is null THEN
NVL2(lom.actual date,
cast(lom.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
lom.scheduled date < CURRENT_DATE THEN
NVL2(lom.actual date,
cast(lom.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
lom.scheduled date >= CURRENT_DATE THEN
NVL2(lom.actual date,
cast(lom.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
lom.scheduled date is null THEN
NVL2(lom.actual date,
cast(lom.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
lom.scheduled date < CURRENT_DATE THEN
NVL2(lom.actual date,
cast(lom.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'planned' and
lom.scheduled date >= CURRENT_DATE THEN
NVL2(lom.actual date,
cast(lom.actual date AS nvarchar2(30)),
'N/A')
end as DER_lom_ACT,
/*lod*/
case
WHEN pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' OR
pt.store status = 'Active' THEN
NVL2(lod.scheduled date,
cast(lod.scheduled date AS nvarchar2(30)),
'Null')
when pt.store status = 'planned' THEN
NVL2(lod.scheduled date,
cast(lod.scheduled date AS nvarchar2(30)),
'Null')
end as DER_lod_SHC,
case
when pt.store status = 'Cancelled' OR
pt.store status = 'Stopped' THEN
cast('N/A' AS nvarchar2(30))
WHEN pt.store status = 'Completed' THEN
NVL2(lod.actual date,
cast(lod.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
lod.scheduled date is null THEN
NVL2(lod.actual date,
cast(lod.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
lod.scheduled date < CURRENT_DATE THEN
NVL2(lod.actual date,
cast(lod.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'Active' and
lod.scheduled date >= CURRENT_DATE THEN
NVL2(lod.actual date,
cast(lod.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
lod.scheduled date is null THEN
NVL2(lod.actual date,
cast(lod.actual date AS nvarchar2(30)),
'N/A')
when pt.store status = 'planned' and
lod.scheduled date < CURRENT_DATE THEN
NVL2(lod.actual date,
cast(lod.actual date AS nvarchar2(30)),
'Null')
when pt.store status = 'planned' and
lod.scheduled date >= CURRENT_DATE THEN
NVL2(lod.actual date,
cast(lod.actual date AS nvarchar2(30)),
'N/A')
end as DER_lod_ACT
from
product table pt,
event table pr,
event table pl,
event table ps,
event table fo,
event table fb,
event table fod,
event table lo,
event table lom,
event table lod
where
pt.product code = pr.product code
and pt.store code = pr.store code
and pt.product code = pl.product code
and pt.store code = pl.store code
and pt.product code = fo.product code
and pt.store code = fo.store code
and pt.product code = fb.product code
and pt.store code = fb.store code
and pt.product code = fod.product code
and pt.store code = fod.store code
and pt.product code = lo.product code
and pt.store code = lo.store code
and pt.product code = lom.product code
and pt.store code = lom.store code
and pt.product code = lod.product code
and pt.store code = lod.store code
and pr.product code=pl.product code
and pl.store code=ps.store code
and ps.product code=fo.product code
and fo.store code=fb.store code
and fb.product code=fod.product code
and fod.store code=lo.store code
and lo.product code=lom.product code
and lom.store code=lod.store code
and pr.event code=1001
and pl.event code=1002
and ps.event code=1003
and fo.event code=1004
and fb.event code=1005
and fod.event code=1006
and lo.event code=1007
and lom.event code=1008
and lod.event code=1009
order by product code,store code;
THANKS IN ADVANCE FOR SPARING YOUR TIME IN UNDERSTANDING MY PROVLEM....
REGARDS,
MYTHRI.986300 wrote:
from
product table pt,
event table pr,
event table pl,
event table ps,
event table fo,
event table fb,
event table fod,
event table lo,
event table lom,
event table lodabove is NOT valid SQL syntax
Maybe you are looking for
-
How to send the 3rd email in the MSMSP CUP workflow?
Hello GRC community, at first thank you all for your great support during the last months. Four month ago I started the implementation of AC in our department without any GRC experience. But now, four months later we are just about to implement the A
-
I can't open safari, safari quit unexpectedly.
Hi can someone help me when I start up my mac book pro with retina display a window pops out saying that safari quit unexpectedly, eventhough from last use i qut safari reguraly. Thanks The details are these: Process: Safari [328] Path:
-
Problem in creating DB Connect source system
Hi All, Iam creating a DB Connect source system to a legacy ORACLE database. Since my legacy database is ORACLE, I have given the TNS name as the connection info. The source system got created successfully. but the problem is, upon clicking on 'datas
-
Slowness of interactive report in SSL
All, Has anyone experienced slow response for Interactive Reports when on https? I just tried running exactly same interactive report in non-SSL mode and it ran at least 2-3 X faster. Anyone aware of any issues with https configuration for Apex. Othe
-
Possible to put DVD's on IPOD VIDEO
I am wondering if it is possible to upload a DVD you own onto your IPOD....If so please help me Please... Thank you