Query join help
Hello everyone, I kindly need help with a query I am trying to write. I think it's meant to be a kind of join but I'm a little unsure. Here is an example:
select a.person_id, a.company, b.name, e.element, f.value
from a, b, e, f
where a.person_id = b.person_id
and e.el_id = f.el_id
-- e.t.c
Lets say this returns
person_id, company, name, element, value
1, Vols, krog, lunch, 34
2, Mols, flog, munch, 24
The problem now is the table e. I want to get all values from table e that meet a certain criteria. As in:
select e.element
where e.name = 'EVALUE'
Lets say this returns
element
food
lunch
munch
And combine it with the top query. But I also want to show all of the other values, a.person_id, a.company, b.name for each row.
So my goal is to have finally:
person_id, company, name, element, value
1, Vols, krog, lunch, 34
1, Vols, krog, food, 0
1, Vols, krog, munch, 0
2, Mols, flog, munch, 24
2, Mols, flog, food, 0
2, Mols, flog, lunch, 0
That is to have a default for zero where no join exists for value and not to duplicate anything although I could still use distinct.
Can anyone help with this?
with t1 as (
select a.person_id, a.company, b.name, e.element, f.value
from a, b, e, f
where a.person_id = b.person_id
and e.el_id = f.el_id
-- e.t.c
t2 as (
select e.element
where e.name = 'EVALUE'
select person_id,
company,
name,
t2.element,
sum(
case t1.element
when t2.element then value
else 0
end
) value
from t1,
t2
group by person_id,
company,
name,
order by person_id,
company,
name,
t2.element
/For example:
with t1 as (
select 1 person_id, 'Vols' company, 'krog' name, 'lunch' element, 34 value from dual union all
select 2, 'Mols', 'flog', 'munch', 24 from dual
t2 as (
select 'food' element from dual union all
select 'lunch' from dual union all
select 'munch' from dual
select person_id,
company,
name,
t2.element,
sum(
case t1.element
when t2.element then value
else 0
end
) value
from t1,
t2
group by person_id,
company,
name,
t2.element
order by person_id,
company,
name,
t2.element
PERSON_ID COMP NAME ELEME VALUE
1 Vols krog food 0
1 Vols krog lunch 34
1 Vols krog munch 0
2 Mols flog food 0
2 Mols flog lunch 0
2 Mols flog munch 24
6 rows selected.
SQL> SY.
Similar Messages
-
I have two tables DEVICE and CONTACT. The tables are joined DEVICE_ID to CONTACT_ID. I want to print device_ID and the corresponding contact info with the lowest CONTACT.PRIORITY.
SQL> describe DEVICE;
DEVICE_ID NOT NULL VARCHAR2(50)
SQL> describe CONTACT;
CONTACT_ID NOT NULL VARCHAR2(50)
CONTACT_TYPE NOT NULL VARCHAR2(4)
PRIORITY NOT NULL DOUBLE PRECISION
LASTNAME NOT NULL VARCHAR2(30)
FIRSTNAME NOT NULL VARCHAR2(80)
SQL> SELECT a.DEVICE_ID, b.LASTNAME,b.PRIORITY from DEVICE a, CONTACT b where a.DEVICE_ID = 'DEVICEA' and a.DEVICE_ID=b.CONTACT_ID(+);
DEVICE_ID LASTNAME FIRSTNAME PRIORITY CONTACT_TYPE
DEVICEA CONTACT1 GN 1 ROUT
DEVICEA CONTACT2 Hans 2 ROUTHow do I print just one record with the lowest CONTACT.PRIORITY?
Thanks
Ravirmalghan wrote:
Thanks Frank, Sundar and Sean. I got the below 3 to work. Two questions. My DEVICE table has 31936 records.
1. The first one returned 30207, 2nd 31936 records and 3rd one 30348. Since the 2nd one result looks like what I expected, the 1st and 3rd one seem to be missing some records. For troubleshooting, I tried to limit the query for a few devices, but can't seem to figure why the difference. Any suggestions? The 2nd query is not checking for CONTACT_TYPE = 'ROUT', so it's not surprising that it returns more rows.
The 3rd query is effectively doing an inner join. The condition "WHERE c.rnum = 1" is being applied after the join, so it rejects all the rows that were added because of the outer join (that is, where all the columns from c are NULL). You probably meant:
LEFT OUTER JOIN got_rnum c ON d.DEVICE_ID = c.CONTACT_ID
AND c.rnum = 1; without a WHERE clause.
2. Is there benefit in terms of efficiency. The 2nd one does seem to run faster so I am guessing that is the best. Any comments?
SELECT a.DEVICE_ID, b.LASTNAME,b.FIRSTNAME,b.PRIORITY
FROM DEVICE a, CONTACT b
where
a.DEVICE_ID=b.CONTACT_ID(+) and
b.CONTACT_TYPE = 'ROUT' and
b.PRIORITY = (select min(b1.PRIORITY ) from CONTACT b1 where b1.CONTACT_ID = b.CONTACT_ID);
30207 rows selected (10.12 seconds)
SELECT DEVICE_ID, LASTNAME, PRIORITY
FROM (
SELECT a.DEVICE_ID, b.LASTNAME, b.PRIORITY, ROW_NUMBER() OVER (PARTITION BY a.DEVICE_ID ORDER BY b.PRIORITY) row_num
from DEVICE a, CONTACT b
where a.DEVICE_ID=b.CONTACT_ID(+))
WHERE row_num = 1;
31936 rows selected (6.68 seconds)
WITH got_rnum AS (
SELECT LASTNAME, FIRSTNAME, PRIORITY, CONTACT_TYPE, CONTACT_ID,
ROW_NUMBER () OVER ( PARTITION BY CONTACT_ID ORDER BY priority) AS rnum
FROM contact
where CONTACT_TYPE = 'ROUT'
SELECT d.DEVICE_ID, c.LASTNAME, c.FIRSTNAME, c.PRIORITY
FROM device d
JOIN got_rnum c ON d.DEVICE_ID = c.CONTACT_ID(+)
WHERE c.rnum = 1;
30348 rows selected (9.07 seconds)
Timing that way isn't very accurate. Whichever one you run first is apt to be slower, because the data is less likely to be cached in memory.
The 2nd query has only 3 columns in the result set. That probably doesn't change the speed much, but you should fix it anyway. -
How to improve the performance of the attached query, Please help
Hi,
How to improve performance of the below query, Please help. also attached explain plan -
SELECT Camp.Id,
rCam.AccountKey,
Camp.Id,
CamBilling.Cpm,
CamBilling.Cpc,
CamBilling.FlatRate,
Camp.CampaignKey,
Camp.AccountKey,
CamBilling.billoncontractedamount,
(SUM(rCam.Impressions) * 0.001 + SUM(rCam.Clickthrus)) AS GR,
rCam.AccountKey as AccountKey
FROM Campaign Camp, rCamSit rCam, CamBilling, Site xSite
WHERE Camp.AccountKey = rCam.AccountKey
AND Camp.AvCampaignKey = rCam.AvCampaignKey
AND Camp.AccountKey = CamBilling.AccountKey
AND Camp.CampaignKey = CamBilling.CampaignKey
AND rCam.AccountKey = xSite.AccountKey
AND rCam.AvSiteKey = xSite.AvSiteKey
AND rCam.RmWhen BETWEEN to_date('01-01-2009', 'DD-MM-YYYY') and
to_date('01-01-2011', 'DD-MM-YYYY')
GROUP By rCam.AccountKey,
Camp.Id,
CamBilling.Cpm,
CamBilling.Cpc,
CamBilling.FlatRate,
Camp.CampaignKey,
Camp.AccountKey,
CamBilling.billoncontractedamount
Explain Plan :-
Description Object_owner Object_name Cost Cardinality Bytes
SELECT STATEMENT, GOAL = ALL_ROWS 14 1 13
SORT AGGREGATE 1 13
VIEW GEMINI_REPORTING 14 1 13
HASH GROUP BY 14 1 103
NESTED LOOPS 13 1 103
HASH JOIN 12 1 85
TABLE ACCESS BY INDEX ROWID GEMINI_REPORTING RCAMSIT 2 4 100
NESTED LOOPS 9 5 325
HASH JOIN 7 1 40
SORT UNIQUE 2 1 18
TABLE ACCESS BY INDEX ROWID GEMINI_PRIMARY SITE 2 1 18
INDEX RANGE SCAN GEMINI_PRIMARY SITE_I0 1 1
TABLE ACCESS FULL GEMINI_PRIMARY SITE 3 27 594
INDEX RANGE SCAN GEMINI_REPORTING RCAMSIT_I 1 1 5
TABLE ACCESS FULL GEMINI_PRIMARY CAMPAIGN 3 127 2540
TABLE ACCESS BY INDEX ROWID GEMINI_PRIMARY CAMBILLING 1 1 18
INDEX UNIQUE SCAN GEMINI_PRIMARY CAMBILLING_U1 0 1Hello,
This has really nothing to do with the Oracle Forms product.
Please, send the SQL or/and PL/SQL questions in the corresponding forums.
Francois -
Using : Oracle 11.2.0.1 on Windows XP
create table tab40(bno varchar2(1),pno varchar2(7),weight number(3),lineno number(3));
insert into tab40 values ('1','1115027',36,1);
insert into tab40 values ('2','1115100',25,2);
insert into tab40 values ('3','1115200',50,3);
insert into tab40 values ('1','1112510',60,4);
insert into tab40 values ('+','1112610',6,5);
insert into tab40 values ('+','1112710',4,6);
insert into tab40 values ('+','1110710',1,7);
insert into tab40 values ('2','1117014',79,8);
insert into tab40 values ('+','1117000',9,9);
insert into tab40 values ('+','1117001',2,10);
insert into tab40 values ('1','1317001',200,11);
insert into tab40 values ('1','1697001',20,12);
insert into tab40 values ('2','2997001',40,13);
insert into tab40 values ('1','2996001',44,14);
SQL> select * from tab40;
B PNO WEIGHT LINENO
1 1115027 36 1
2 1115100 25 2
3 1115200 50 3
1 1112510 60 4
+ 1112610 6 5
+ 1112710 4 6
+ 1110710 1 7
2 1117014 79 8
+ 1117000 9 9
+ 1117001 2 10
1 1317001 200 11
B PNO WEIGHT LINENO
1 1697001 20 12
2 2997001 40 13
1 2996001 44 14
14 rows selected.
SQL>create table tab41(bno varchar2(1),pno varchar2(7),weight number(3),lineno number(3));
insert into tab41 values ('1','1115027',36,1);
insert into tab41 values ('2','1115100',25,2);
insert into tab41 values ('3','1115200',50,3);
insert into tab41 values ('1','1112510',60,4);
insert into tab41 values ('+','1112610',6,5);
insert into tab41 values ('+','1110710',1,6);
insert into tab41 values ('2','1117014',79,7);
insert into tab41 values ('+','1117000',9,8);
insert into tab41 values ('1','1317001',200,9);
insert into tab41 values ('1','1697001',20,10);
insert into tab41 values ('2','2997001',40,11);
insert into tab41 values ('1','2996001',44,12);
insert into tab41 values ('+','1112710',4,13);
insert into tab41 values ('+','3332710',8,14);
SQL> select * from tab41;
B PNO WEIGHT LINENO
1 1115027 36 1
2 1115100 25 2
3 1115200 50 3
1 1112510 60 4
+ 1112610 6 5
+ 1110710 1 6
2 1117014 79 7
+ 1117000 9 8
1 1317001 200 9
1 1697001 20 10
2 2997001 40 11
B PNO WEIGHT LINENO
1 2996001 44 12
+ 1112710 4 13
+ 3332710 8 14
14 rows selected.
SQL>Required Output :
A B C D E F G H
1 1112510 60 4 1 2996001 44 12
+ 1112710 4 6 + 1112710 4 13
2 1117014 79 8
+ 1117001 2 10
1 2996001 44 12
+ 3332710 8 14Logic : The plus sign in Bno indicates that Packet No. was sent to customer with last non plus signed number packet (order by lineno) i.e. for example in tab40 there is line no. 6 whose master packet number is 1112510 (previous non plus signed rows's PNO). Now come to required output; which is showing that these plus signed packets (whose master PNO is that) are not as per tab40 vs tab41 something like full outer join between tab40 and tab41. Example :
+ 1112710 is associated with 1112510 in tab40, while in tab41 it is associated with 2996001; so it is difference.
+ 1117001 is associated with 1117014 in tab40, while it is not in tab41.
vice versa;
+ 3332710 is associated with 2996001 in tab41, while it is not in tab40.
I mean, if only plus marked row's PNO's mater packet number is not equal to master PNO(previous non plus marked BNO) in both the table, it should be part of the select query please. Generally this happens, when our packing department gets late delivery of prior master packet, so they just send the small packet with immediate available one (non plus) packet.
Kindly let me; i am clear in my request or i should elaborate more. This may be more complex, because may be bad table/data design, but i need the output by select query please help me.
Regards.
Edited by: user12050217 on Jan 3, 2012 3:57 AMYes, you have perfectly understood my question... just i added lineno > 1
SELECT bno,
pno,
weight,
lineno
FROM ( SELECT tab40.*, lag (bno) OVER (ORDER BY pno) prev_bno
FROM tab40
ORDER BY pno)
WHERE bno = '+' OR prev_bno = '+' and lineno > 1
ORDER BY lineno
and it worked, because there are no chances that plus marked row will be having lineno <=1
B PNO WEIGHT LINENO
1 1112510 60 4
+ 1112610 6 5
+ 1112710 4 6
+ 1110710 1 7
2 1117014 79 8
+ 1117000 9 9
+ 1117001 2 10
7 rows selected. -
Does anyone see any issues in my query/join?
Select c.case_id, a.business_unit, a.field_name, a.change_date, a.old_value, a.new_value, a.created_by, a.creation_date, c.provider_group_id, c.creation_date, c.closed_dttm
From ps_case c, ps_case_history_audit a
where
a.case_id = c.case_id and
a.field_name = 'case_status' and
a.new_value = 'Open - Dispatch' and
a.created_by like '%tag%' and
c.provider_group_id like '%tag%' and
c.closed_dttm between '03-NOV-2013' and '10-NOV-2013'
SQL Dev: All Rows Fetched: 0 But it should be returning something with the stated parameters.Hi,
I'm willing to share what I know about SQL to help solve this problem. Are you willing to share what you know about the data and the application?
Whenever you have a question, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you expect from that data.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
"0 rows found" is sometimes the correct answer. Why do you think it's not in this case?
If c.closed_dttm is a DATE (or a TIMESTAMP) then you shouldn't be comparing it to strings, as in
c.closed_dttm between '03-NOV-2013' and '10-NOV-2013'
However, that would probably produce too many rows in this case, not too few.
At any rate, compare DATEs to other DATEs, for example
c.closed_dttm between TO_DATE ('03-NOV-2013', 'DD-MON-YYYY') and ...
If this isn't the cause of today's problem today, it will be tomorrow's. -
Query/join/where/child parent table
query/join/where/child parent table
hello my query below is not working for my cf application can
you help?
thanks
this is my previous question so i tried to do it my self.
tcase_req.tcase_req_id is added
tcase.case_id=tcase_req.case_id :note that this is not part of the
inner join in the from clause. it does not depend on the rest of
the inner join.
the reaon for this is that i need to get
WHERE tcase_req.case_req_typ_cd = cwc and
tcase_req.case_req_typ_cd = cwnc
here is the original question
Hello ,
I need help again on the inner join/and conditions in the
where clause
I have these 2 tables tcase and tcase_req where there common
field Is the case_id.
tcase is the parent table and the tcase_req is the child
table.
(1)I wanted to add this to the from clause using the inner
join table . what do I do and where do I put it
(2)I then need to put a condition in the where clause to
replace
WHERE TCASE.CASE_NBR Like '%HPOZ%'
AND TCASE.CASE_NBR = 'DIR-2004-4269-HPOZ-CCMP'
by
WHERE TCASE.CASE_NBR Like '%CWC%' or TCASE.CASE _NBR Like
'%CWNC%'
AND TCASE.CASE_NBR = 'DIR-2004-4269-CWC'
Or TCASE.CASE_NBR = 'DIR-2004-4269-CWNC'
is this efficient??
thanks
SELECT TLA_PROP.PIN,
TLA_PROP.ASSR_PRCL_NBR,
TCASE.CASE_NBR,
TLA_PROP.STR_NBR,
TLA_PROP.STR_NBR_RNG_END,
TLA_PROP.STR_FRAC_NBR,
Tref_plan_area.plan_area_desc,
TLA_PROP.STR_FRAC_NBR_RNG_END,
TLA_PROP.STR_DIR_CD,
TLA_PROP.STR_NM,
TLA_PROP.STR_SFX_CD,
TLA_PROP.STR_SFX_DIR_CD,
TLA_PROP.STR_UNIT_TYP_CD,
TLA_PROP.UNIT_NBR,
TLA_PROP.UNIT_NBR_RNG_END,
TLA_PROP.ZIP_CD,
TLA_PROP.ZIP_CD_SFX,
TLA_PROP.CNCL_DIST_NBR,
TLA_PROP.PLAN_AREA_NBR,
TLA_PROP.ZONE_REG_CD,
TAPLC.PROJ_DESC_TXT,
TCASE.CASE_ID,
TCASE.CASE_NBR,
taplc.aplc_id,
tcase_req.case_req_typ_cd
FROM TLA_PROP INNER JOIN tref_plan_area ON
tla_prop.plan_area_nbr = tref_plan_area.plan_area_NBR INNER JOIN
TLOC ON TLA_PROP.PROP_ID = TLOC.LOC_ID INNER JOIN TAPLC ON
TLOC.APLC_ID = TAPLC.APLC_ID INNER JOIN TCASE ON TAPLC.APLC_ID =
TCASE.APLC_ID
WHERE TCASE.CASE_NBR Like '%CWC%'and
tcase.case_id=tcase_req.case_id
(3)To a tcase_req
Suffix_id are equal to = cwc and cwnc ( in the tcase_req
table)(Suffix_id is the field that cintains the suffix cwc and cwnc
for the tcase_req)
also,
this is the original query and it works fine
SELECT TLA_PROP.PIN,
TLA_PROP.ASSR_PRCL_NBR,
TCASE.CASE_NBR,
TLA_PROP.STR_NBR,
TLA_PROP.STR_NBR_RNG_END,
TLA_PROP.STR_FRAC_NBR,
Tref_plan_area.plan_area_desc,
TLA_PROP.STR_FRAC_NBR_RNG_END,
TLA_PROP.STR_DIR_CD,
TLA_PROP.STR_NM,
TLA_PROP.STR_SFX_CD,
TLA_PROP.STR_SFX_DIR_CD,
TLA_PROP.STR_UNIT_TYP_CD,
TLA_PROP.UNIT_NBR,
TLA_PROP.UNIT_NBR_RNG_END,
TLA_PROP.ZIP_CD,
TLA_PROP.ZIP_CD_SFX,
TLA_PROP.CNCL_DIST_NBR,
TLA_PROP.PLAN_AREA_NBR,
TLA_PROP.ZONE_REG_CD,
TAPLC.PROJ_DESC_TXT,
TCASE.CASE_ID,
TCASE.CASE_NBR,
taplc.aplc_id
FROM TLA_PROP INNER JOIN tref_plan_area ON
tla_prop.plan_area_nbr = tref_plan_area.plan_area_NBR INNER JOIN
TLOC ON TLA_PROP.PROP_ID = TLOC.LOC_ID INNER JOIN TAPLC ON
TLOC.APLC_ID = TAPLC.APLC_ID INNER JOIN TCASE ON TAPLC.APLC_ID =
TCASE.APLC_ID
WHERE (TCASE.CASE_NBR Like '%CWC%' or TCASE.CASE_NBR Like
'%CWNC%')query/join/where/child parent table
hello my query below is not working for my cf application can
you help?
thanks
this is my previous question so i tried to do it my self.
tcase_req.tcase_req_id is added
tcase.case_id=tcase_req.case_id :note that this is not part of the
inner join in the from clause. it does not depend on the rest of
the inner join.
the reaon for this is that i need to get
WHERE tcase_req.case_req_typ_cd = cwc and
tcase_req.case_req_typ_cd = cwnc
here is the original question
Hello ,
I need help again on the inner join/and conditions in the
where clause
I have these 2 tables tcase and tcase_req where there common
field Is the case_id.
tcase is the parent table and the tcase_req is the child
table.
(1)I wanted to add this to the from clause using the inner
join table . what do I do and where do I put it
(2)I then need to put a condition in the where clause to
replace
WHERE TCASE.CASE_NBR Like '%HPOZ%'
AND TCASE.CASE_NBR = 'DIR-2004-4269-HPOZ-CCMP'
by
WHERE TCASE.CASE_NBR Like '%CWC%' or TCASE.CASE _NBR Like
'%CWNC%'
AND TCASE.CASE_NBR = 'DIR-2004-4269-CWC'
Or TCASE.CASE_NBR = 'DIR-2004-4269-CWNC'
is this efficient??
thanks
SELECT TLA_PROP.PIN,
TLA_PROP.ASSR_PRCL_NBR,
TCASE.CASE_NBR,
TLA_PROP.STR_NBR,
TLA_PROP.STR_NBR_RNG_END,
TLA_PROP.STR_FRAC_NBR,
Tref_plan_area.plan_area_desc,
TLA_PROP.STR_FRAC_NBR_RNG_END,
TLA_PROP.STR_DIR_CD,
TLA_PROP.STR_NM,
TLA_PROP.STR_SFX_CD,
TLA_PROP.STR_SFX_DIR_CD,
TLA_PROP.STR_UNIT_TYP_CD,
TLA_PROP.UNIT_NBR,
TLA_PROP.UNIT_NBR_RNG_END,
TLA_PROP.ZIP_CD,
TLA_PROP.ZIP_CD_SFX,
TLA_PROP.CNCL_DIST_NBR,
TLA_PROP.PLAN_AREA_NBR,
TLA_PROP.ZONE_REG_CD,
TAPLC.PROJ_DESC_TXT,
TCASE.CASE_ID,
TCASE.CASE_NBR,
taplc.aplc_id,
tcase_req.case_req_typ_cd
FROM TLA_PROP INNER JOIN tref_plan_area ON
tla_prop.plan_area_nbr = tref_plan_area.plan_area_NBR INNER JOIN
TLOC ON TLA_PROP.PROP_ID = TLOC.LOC_ID INNER JOIN TAPLC ON
TLOC.APLC_ID = TAPLC.APLC_ID INNER JOIN TCASE ON TAPLC.APLC_ID =
TCASE.APLC_ID
WHERE TCASE.CASE_NBR Like '%CWC%'and
tcase.case_id=tcase_req.case_id
(3)To a tcase_req
Suffix_id are equal to = cwc and cwnc ( in the tcase_req
table)(Suffix_id is the field that cintains the suffix cwc and cwnc
for the tcase_req)
also,
this is the original query and it works fine
SELECT TLA_PROP.PIN,
TLA_PROP.ASSR_PRCL_NBR,
TCASE.CASE_NBR,
TLA_PROP.STR_NBR,
TLA_PROP.STR_NBR_RNG_END,
TLA_PROP.STR_FRAC_NBR,
Tref_plan_area.plan_area_desc,
TLA_PROP.STR_FRAC_NBR_RNG_END,
TLA_PROP.STR_DIR_CD,
TLA_PROP.STR_NM,
TLA_PROP.STR_SFX_CD,
TLA_PROP.STR_SFX_DIR_CD,
TLA_PROP.STR_UNIT_TYP_CD,
TLA_PROP.UNIT_NBR,
TLA_PROP.UNIT_NBR_RNG_END,
TLA_PROP.ZIP_CD,
TLA_PROP.ZIP_CD_SFX,
TLA_PROP.CNCL_DIST_NBR,
TLA_PROP.PLAN_AREA_NBR,
TLA_PROP.ZONE_REG_CD,
TAPLC.PROJ_DESC_TXT,
TCASE.CASE_ID,
TCASE.CASE_NBR,
taplc.aplc_id
FROM TLA_PROP INNER JOIN tref_plan_area ON
tla_prop.plan_area_nbr = tref_plan_area.plan_area_NBR INNER JOIN
TLOC ON TLA_PROP.PROP_ID = TLOC.LOC_ID INNER JOIN TAPLC ON
TLOC.APLC_ID = TAPLC.APLC_ID INNER JOIN TCASE ON TAPLC.APLC_ID =
TCASE.APLC_ID
WHERE (TCASE.CASE_NBR Like '%CWC%' or TCASE.CASE_NBR Like
'%CWNC%') -
Dear all,
I'm trying to create a query joining 2 tables: CATSDB and PROJ, because I want to visualize the project and the wbs at the same time according the working time recorded in cat2.
But when I execute the query doesn't appear any values. But if I create a query separately, i.e, table by table, the values appears without problems.
Please anyone can help me???
Thanks,
P.There should be Field/s that link these tables in order for you to create an infoset out of a table join.
e.g. PA0008 and PA0007 both have the field PERNR.
If there is no field common between the two, your query won't be extracting any data as you've experienced.
These two tables don't have any field that is common to both of them. Table join won't be possible. -
I had written the below qery : its showing error that:for pooled tble,cluster tble,projection veiws join is not allowd : 'CDPOS'.
SELECT ekkoebeln cdhdrudate cdhdrtcode cdhdrtabname INTO CORRESPONDING FIELDS OF TABLE it_cdhdr
FROM ( ( ekko AS ekko INNER JOIN cdhdr AS cdhdr ON ekkoebeln = cdhdrobjectid )
INNER JOIN cdpos AS cdpos ON ekkoebeln = cdposobjectid )
WHERE ekko~ebeln = i_ebeln AND
ekko~frgke EQ 'R' AND
ekko~procstat EQ '05' AND
cdhdr~tcode IN ('ME29N' , 'ME28') AND
cdpos~tabname = 'EKKO'
GROUP BY ekko~ebeln
ekko~frgke
ekko~procstat
cdhdr~udate
cdhdr~tcode
cdpos~tabname.
so what shd i do,i need this table for the fetching data.
Plz tell me any way to solve this......its Urgent!!!!!!!!!!!!!!!!!!
Regards
VipinHi Vipin,
U can't perform JOIN with Pooled or Cluster tables
And U can use only Internal table after FOR ALL ENTRIES <internal table>
Try to store whole data of CDPOS in the internal table and then use it..
See below links to get idea on how to work with cluster and pooled tables...
trying to join A018 and KONP .... here A018 is Pooled table... Look at below threads...
Re: abap query join A018/KONP
Can't perform join table
Hope it will solve your problem..
<b>Reward points if useful.</b>
Thanks & Regards
ilesh 24x7 -
Cluster bar chart- sql query please help-
Hi,
I am trying to create cluster bar chart and am stumped with this sql query.Any help is appreciated.
Here is my table
city region issue value
c1 north i1 y
c1 north i2 y
c2 north i1 n
c2 north i2 y
c3 south i1 y
c3 south i2 n
c4 east i1 n
c4 east i2 n
The bar chart will have 3 series, north south and east.
And labels will be i1 and i2. value will be number of times this issue was encountered(y) in this region.
How can I get something like this from the above table-
region issue count(yes)
north i1 1
north i2 2
south i1 1
south i2 0
east i1 0
east i2 0
thanksWITH table1 AS
(SELECT 1435177 qte_id, 2 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no
FROM dual
table2 AS
SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
FROM dual
SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
FROM
(SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
FROM table1 t1, table2 t2
WHERE t2.qte_id = t1.qte_id (+)
AND t2.seq_no = t1.seq_no(+)
ORDER BY 1,2
WHERE t1_seq_no IS NOT NULL
ORDER BY 1,2
QTE_ID T2_SEQ_NO DIFF
1435177 2 0
1435177 5 0
1435177 7 0
1435177 8 0
1435177 12 0
1435177 14 0 -
I am trying to write a query to return data from 4 different tables and it is doubling my summed values. I can get the separate queries to work, but not combined and I need them combined so that I can get a balance due and limit the records to only those that had a total billed (fees) less than $200.
Query #1 Gets the total of the fees due for each appeal type and invoice:
Note: There is always at least one fee attached to an invoice.
SELECT APT.APTY_DESCR "APPEAL TYPE",
INV.INVC_ID_SEQ INVOICE,
SUM( ALL FEE.AMT_DUE) "TOTAL BILLED AMOUNT"
FROM WRD_APPEALS AP,
WRD_INVOICES INV,
WRD_FEES_DUE FEE,
WRD_APPEAL_TYPES APT
WHERE AP.APST_CD = 'PEND'
AND AP.INVC_ID_SEQ = INV.INVC_ID_SEQ
AND AP.INVC_ID_SEQ = FEE.INVC_ID_SEQ
AND AP.APTY_CD = APT.APTY_CD
GROUP BY APT.APTY_DESCR, INV.INVC_ID_SEQ
ORDER BY APT.APTY_DESCR, INV.INVC_ID_SEQ
4 BILLING CATEGORY INCORRECT 4147 1200
5 BILLING CATEGORY INCORRECT 4203 1100
6 BILLING CATEGORY INCORRECT 4216 72600
7 BILLING CATEGORY INCORRECT 4826 1000
8 BILLING CATEGORY INCORRECT 4951 2060
Query #2 Gets the total amount paid for each appeal type and invoice:
Note: An invoice may or may not have a payment, thus the outer join.
SELECT APT.APTY_DESCR "APPEAL TYPE",
INV.INVC_ID_SEQ INVOICE,
SUM(ALL PMT.PAID_AMT) "AMOUNT PAID"
FROM WRD_APPEALS AP,
WRD_INVOICES INV,
WRD_APPEAL_TYPES APT,
WRD_PAYMENTS PMT
WHERE AP.APST_CD = 'PEND'
AND AP.INVC_ID_SEQ = INV.INVC_ID_SEQ
AND AP.APTY_CD = APT.APTY_CD
AND INV.INVC_ID_SEQ = PMT.INVC_ID_SEQ(+)
GROUP BY APT.APTY_DESCR, INV.INVC_ID_SEQ
ORDER BY APT.APTY_DESCR, INV.INVC_ID_SEQ
4 BILLING CATEGORY INCORRECT 4147 200
5 BILLING CATEGORY INCORRECT 4203 0
6 BILLING CATEGORY INCORRECT 4216 72600
7 BILLING CATEGORY INCORRECT 4826
8 BILLING CATEGORY INCORRECT 4951
Combined Query - Gets all of the above as well as the balance due. Note the doubled values for some records.
SELECT APT.APTY_DESCR "APPEAL TYPE",
INV.INVC_ID_SEQ INVOICE,
SUM( ALL FEE.AMT_DUE) "TOTAL BILLED AMOUNT",
SUM(ALL PMT.PAID_AMT) "AMOUNT PAID",
(SUM(ALL FEE.AMT_DUE) -
NVL2(SUM(ALL PMT.PAID_AMT), SUM(ALL PMT.PAID_AMT), 0)) "BALANCE DUE"
FROM WRD_APPEALS AP,
WRD_INVOICES INV,
WRD_FEES_DUE FEE,
WRD_APPEAL_TYPES APT,
WRD_PAYMENTS PMT
WHERE AP.APST_CD = 'PEND'
AND AP.INVC_ID_SEQ = INV.INVC_ID_SEQ
AND INV.INVC_ID_SEQ = PMT.INVC_ID_SEQ(+)
AND INV.INVC_ID_SEQ = FEE.INVC_ID_SEQ
AND AP.APTY_CD = APT.APTY_CD
GROUP BY APT.APTY_DESCR, INV.INVC_ID_SEQ
ORDER BY APT.APTY_DESCR, INV.INVC_ID_SEQ,
4 BILLING CATEGORY INCORRECT 4147 1200 400 800
5 BILLING CATEGORY INCORRECT 4203 2200 0 2200
6 BILLING CATEGORY INCORRECT 4216 72600 435600 -363000
7 BILLING CATEGORY INCORRECT 4826 1000 1000
8 BILLING CATEGORY INCORRECT 4951 2060 2060
HELP PLEASE!
Thank you.When you have multiple child rows, the parent row gets returned once for each child row found. Therefore, if you have summed the invoice, it gets summed again for each payment. Perhaps this little example will help you understand the problem.
Note that I used a sub query here to obtain the desired results. Analytic functions can do the same I believe, but I am still learning them :-)
D> DROP TABLE DMILL.invoice;
Table dropped.
D>
D> DROP TABLE DMILL.payments;
Table dropped.
D>
D> CREATE TABLE invoice AS
SELECT 1 id, 10 amount FROM DUAL UNION ALL
SELECT 2 id, 10 FROM DUAL UNION ALL
SELECT 2 id, 10 FROM DUAL UNION ALL
SELECT 3 id, 10 FROM DUAL;
Table created.
D>
D> CREATE TABLE payments AS
SELECT 1 inv_id, 5 amount FROM DUAL UNION ALL
SELECT 1 inv_id, 5 amount FROM DUAL UNION ALL
SELECT 2 inv_id, 5 amount FROM DUAL UNION ALL
SELECT 2 inv_id, 5 amount FROM DUAL UNION ALL
SELECT 2 inv_id, 5 amount FROM DUAL;
Table created.
D>
D> select * from invoice;
ID AMOUNT
1 10
2 10
2 10
3 10
D>
D> select * from payments;
INV_ID AMOUNT
1 5
1 5
2 5
2 5
2 5
D>
D> select id
,sum (amount)
from invoice
group by id;
ID SUM(AMOUNT)
1 10
2 20
3 10
D>
D> select inv_id
,sum(amount)
from payments
group by inv_id;
INV_ID SUM(AMOUNT)
1 10
2 15
D>
D> select inv.id
,inv.amount
,pay.amount
from invoice inv
,payments pay
where pay.inv_id = inv.id;
ID AMOUNT AMOUNT
1 10 5
1 10 5
2 10 5
2 10 5
2 10 5
2 10 5
2 10 5
2 10 5
8 rows selected.
D>
D> select inv.id
,sum(inv.amount)
,sum(pay.amount)
from invoice inv
,payments pay
where pay.inv_id = inv.id
group by inv.id;
ID SUM(INV.AMOUNT) SUM(PAY.AMOUNT)
1 20 10
2 60 30
D>
D> select inv.id
,sum(inv.amount)
,(SELECT sum(pay.amount)
FROM payments pay
WHERE pay.inv_id = inv.id)
from invoice inv
group by inv.id;
ID SUM(INV.AMOUNT) (SELECTSUM(PAY.AMOUNT)FROMPAYMENTSPAYWHEREPAY.INV_ID=INV.ID)
1 10 10
2 20 15
3 10Let me know if you need further explanation. -
Query with FULL OUTER JOIN , help pleaseeeeeeeeeeee...
Hi everyone,
I'm trying to write a query for a report in Oracle SQL, but i just can't figure out how to do it.
I'm using Oracle 10g release 1.0 database and i execute my queris in SQL* PLUS ( eventually i'm gonna use them in Oracle Report Builder ) .
here's what i have:
i have four tables that are used for our inventory application. lets call them INCOMMING , INCOMMING_ITEMS , OUTGOING , OUTGOING_ITEMS.
as you may have guessed , INCOMMING_ITEMS is the detail table for INCOMMING ( joined by IID column) and also OUTGOING_ITEMS is the detail table for OUTGOING ( joined by OID column ).
here is the structure of them :
INCOMMING
IID varchar2
CDATE date
INCOMMING_ITEM
IID varchar2
PART_NO number
QTY number
OUTGOING
OID varchar2
CDATE date
OUTGOING_ITEM
OID varchar2
PART_NO number
QTY number
now , the query i want, should return part_no , cdate , sum of OUTGOING qty , sum of INCOMMING qty .
the result of the query should be sth like this :
part_no cdate O_qty I_qty
100 01/05/06 10 0
100 01/05/07 20 60
200 01/06/02 0 50
300 01/06/02 30 40
this means that for some dates and for some parts, i may not have INCOMMING or OUTGOING data, but if at least one of the 2 last columns has a non-zero data, i should show the row ( like the first and third rows of my example result), and if both have data for the same PART_NO and the same CDATE, both should be showed in the same row. ( like the second row in my example result)
i tried so much and came up with several huge and also time consuming queries, but then i read abt FULL OUTER JOIN somewhere and tried using that. here is what i came up with :
SELECT
PART_NO , CDATE , sum(II.QTY) I_QTY , SUM (OI.QTY) O_QTY
FROM
(OUTGOING O INNER JOIN OUTGOING_ITEM OI USING ( OID ) )
FULL OUTER JOIN
(INCOMMING I INNER JOIN INCOMMING_ITEM II USING ( IID ) )
ON ( I.CDATE = O.CDATE AND II.PART_NO = OI.PART_NO)
WHERE
I.CDATE = :PARAMETER1
AND O.CDATE = :PARAMETER1
GROUP BY
PART_NO , CDATE
this query is short and fast , but the results r not what i expected. i mean, although i have used FULL OUTER JOIN in the query , but the results i get r sth like this :
part_no cdate O_qty I_qty
100 01/05/07 20 60
300 01/06/02 30 40
which means only the rows that has both values are returned.
any change i make to this query would make the SQL* PLUS hang , like when i use the cartesian product of two large tables, so i guess my changes wheren't in the right direction.
i think its possible to write this query using FULL OUTER JOIN syntax, but i just can't find it.
Can anybody pleaseeeeeeeeeeeee help me?
thanx in advance,
Maryam.Note: I wrote this on the fly -- hope there is no syntax errors, otherwise forgive me -- but you get the idea..
select
fromUnionAll.cdate, fromUnionAll.part_no,
sum(fromUnionAll.O_qty) O_qty,
sum(fromUnionAll.I_qty) I_qty
from
select
iinner.cdate, iinner.part_no, 0 O_qty, iinner.I_qty
from
select
i.cdate, ii.part_no,
/* added the case only for the extreme case when there is
no record anywhere for the given CDATE in INCOMMING_item */
sum( ( case when ii.qty is not null then ii.qty else 0 end) ) I_qty
from
incomming i,
incomming_item ii
where
i.iid = ii.iid (+)
group by i.cdate, ii.part_no
) iinner
union all
select
oinner.cdate, oinner.part_no, oinner.O_qty, 0 I_qty
from
select
o.cdate, oi.part_no,
/* added the case only for the extreme case when there is
no record anywhere for the given CDATE in OUTGOING_item */
sum( ( case when oi.qty is not null then oi.qty else 0 end) ) O_qty
from
outgoing o,
outgoing_item oi
where
o.oid = oi.oid (+)
group by o.cdate, oi.part_no
) oinner
) fromUnionAll
group by fromUnionAll.cdate, fromUnionAll.part_no;
--Samson -
Hi guys, i'm new to the forum. currently i'm taking a computer information tech diploma course and am in entry level database.
Ive struggled my way through this assignment.. I don't want free answers but im done everything except one view and a bonus question. Can someone help me ? not just the answer but an explination.. I'm finding Joins and Subqueries very hard to wrap my head around.. anyways here are the two questions:
6) To help the front desk clerk do guest billings, [a - 6 marks, b - 2 marks]
(a) create a view to calculate the account (i.e. running total todate) for each guest at the Grosvenor Hotel; the view should include the room number, guest name, check-in date, check-out date (today), room rate, the duration in days, and the calculated total dollars
(b) write a SELECT query to demonstrate your view (Use 2007-10-09 as current date if needed).
Optional Bonus Question: up to 10 marks but restricted by allowable maximum for course:
7) Find the most commonly booked room type(s) for each hotel in London? For each hotel, list the hotel number, room type and the number of bookings.
Here are the tables, let me know if you need the data inserted.
CREATE TABLE Hotel
(hotelNo NUMBER(4) NOT NULL
,hotelName VARCHAR2(16) NOT NULL
,hotelAddress VARCHAR2(40) NOT NULL
,PRIMARY KEY (hotelNo)
CREATE TABLE Room
(hotelNo NUMBER(4) NOT NULL
,roomNo NUMBER(4) NOT NULL
,type VARCHAR2(8) NOT NULL
,price NUMBER(6,2) NOT NULL
,PRIMARY KEY (hotelNo, roomNo)
CREATE TABLE Guest
(guestNo NUMBER(4) NOT NULL
,guestName VARCHAR2(15) NOT NULL
,guestAddress VARCHAR2(40) NOT NULL
,PRIMARY KEY (guestNo)
CREATE TABLE Booking
(hotelNo NUMBER(4) NOT NULL
,guestNo NUMBER(4) NOT NULL
,dateFrom DATE NOT NULL
,dateTo DATE
,roomNo NUMBER(4) NOT NULL
,PRIMARY KEY (hotelNo, guestNo, dateFrom)
thank you, and go easy :}
Edit/Delete MessageJohn CIT,
I would advise you to visit here
http://www.oracle.com/pls/db92/db92.federated_search
You will information regarding creating views, etc.
After reading the documentation if you still have
doubts. Then please ask.
The whole point at least from my end is that I should
see some of your effort too for the problem that has
been stated.
Good luck
AdithI agree, ive tried to make both work and failed or else i wouldnt have posted..
I know for the view (#6) I have to select guestNo, roomNo, dateFrom, dateTo, price, dateFrom, price*(dateFrom-dateTo).. im just not sure how to join them all together properly.
for #7 im going to have to use a count aggregate from rooms in the booking table thats joined with Hotel..
ive been working on this man im just confused. at least point me in the right direction?
thanks for response -
Can anyone point me in the right direction for doing joins in query builder?
Thanks!
Brian
[email protected]Click on the left side of the screen at the
arrow. Type in the where clause without
actually typing in "where". You can actually include the columns in the where clause by checking on the columns in the tables present on the right side. Once you are done, press ENTER.
You are done creating where clause. You can look at the SQL it created for you by clicking on the menu button called "show SQL".
Hope that helps,
Oracle University Instructor.
P.S: If you attend one of our reports or forms - I class we teach this in class. Moreover, the course material we give out has a complete section on Report Builder.
Go to http:\\education.oracle.com for more info on class info.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Brian Burk ([email protected]):
Can anyone point me in the right direction for doing joins in query builder?
Thanks!
Brian
[email protected]<HR></BLOCKQUOTE>
null -
Need help with query joining several tables into a single return line
what i have:
tableA:
puid, task
id0, task0
id1, task1
id2, task2
tableB:
puid, seq, state
id0, 0, foo
id0, 1, bar
id0, 2, me
id1, 0, foo
id2, 0, foo
id2, 1, bar
tableC:
puid, seq, date
id0, 0, 12/21
id0, 1, 12/22
id0, 2, 12/22
id1, 0, 12/23
id2, 0, 12/22
id2, 1, 12/23
what i'd like to return:
id0, task0, 12/21, 12/22, 12/22
id1, task1, 12/23, N/A, N/A
id2, task2, 12/22, 12/23, N/A
N/A doesn't mean return the string "N/A"... it just means there was no value, so we don't need anything in this column (null?)
i can get output like below through several joins, however i was hoping to condense each "id" into a single line...
id0, task0, 12/21
id0, task0, 12/22
id0, task0, 12/23
id1, task1, 12/23
is this possible fairly easily?
Edited by: user9979830 on Mar 29, 2011 10:53 AM
Edited by: user9979830 on Mar 29, 2011 10:58 AMHi,
Welcome to the forum!
user9979830 wrote:
what i have:...Thanks for posting that so clearly!
Whenever you have a question, it's even better if you post CREATE TABLE and INSERT statements for your sample data, like this:
CREATE TABLE tablea
( puid VARCHAR2 (5)
, task VARCHAR2 (5)
INSERT INTO tablea (puid, task) VALUES ('id0', 'task0');
INSERT INTO tablea (puid, task) VALUES ('id1', 'task1');
INSERT INTO tablea (puid, task) VALUES ('id2', 'task2');
CREATE TABLE tablec
( puid VARCHAR2 (5)
, seq NUMBER (3)
, dt DATE -- DATE is not a good column name
INSERT INTO tablec (puid, seq, dt) VALUES ('id0', 0, DATE '2010-12-21');
INSERT INTO tablec (puid, seq, dt) VALUES ('id0', 1, DATE '2010-12-22');
INSERT INTO tablec (puid, seq, dt) VALUES ('id0', 2, DATE '2010-12-22');
INSERT INTO tablec (puid, seq, dt) VALUES ('id1', 0, DATE '2010-12-23');
INSERT INTO tablec (puid, seq, dt) VALUES ('id2', 0, DATE '2010-12-22');
INSERT INTO tablec (puid, seq, dt) VALUES ('id2', 1, DATE '2010-12-23');This way, people can re-create the problem and test their ideas.
It doesn't look like tableb plays any role in this problem, so I didn't post it.
Explain how you get the results from that data. For example, why do you want this row in the results:
PUID TASK DT1 DT2 DT3
id0 task0 12/21/2010 12/22/2010 12/22/2010rather than, say
PUID TASK DT1 DT2 DT3
id0 task0 12/22/2010 12/21/2010 12/22/2010? Does 12/21 have to go in the first column because it is the earliest date, or is it because 12/21 is related to the lowest seq value? Or do you even care about the order, just as long as all 3 dates are shown?
Always say what version of Oracle you're uisng. The query below will work in Oracle 9 (and up), but starting in Oracle 11, the SELECT ... PIVOT feature could help you.
i can get output like below through several joins, however i was hoping to condense each "id" into a single line... Condensing the output, so that there's only one line for each puid, sounds like a job for "GROUP BY puid":
WITH got_r_num AS
SELECT puid
, dt
, ROW_NUMBER () OVER ( PARTITION BY puid
ORDER BY seq -- and/or dt
) AS r_num
FROM tablec
-- WHERE ... -- If you need any filtering, put it here
SELECT a.puid
, a.task
, MIN (CASE WHEN r.r_num = 1 THEN r.dt END) AS dt1
, MIN (CASE WHEN r.r_num = 2 THEN r.dt END) AS dt2
, MIN (CASE WHEN r.r_num = 3 THEN r.dt END) AS dt3
, MIN (CASE WHEN r.r_num = 4 THEN r.dt END) AS dt4
FROM tablea a
JOIN got_r_num r ON a.puid = r.puid
GROUP BY a.puid
, a.task
ORDER BY a.puid
;I'm guessing that you want the dates arranged by seq; that is, for each puid, the date related to the lowest seq comes first, regardless of whther that date is the earliest date for that puid or not. If that's not what you need, then change the analytic ORDER BY clause.
This does not assume that the seq values are always consecutive integers (0, 1, 2, ...) for each puid. You can skip, or even duplicate values. However, if the values are always consecutive integers, starting from 0, then you could simplify this. You won't need a sub-query at all; just use seq instead of r_num in the main query.
Here's the output I got from the query above:
PUID TASK DT1 DT2 DT3 DT4
id0 task0 12/21/2010 12/22/2010 12/22/2010
id1 task1 12/23/2010
id2 task2 12/22/2010 12/23/2010As posted, the query will display the first 4 dts for each puid.
If there are fewer than 4 dts for a puid, the query will still work. It will leave some columns NULL at the end.
If there are more than 4 dts for a puid, the query will still work. It will display the first 4, and ignore the others.
There's nothing special about the number 4; you could make it 3, or 5, or 35, but whatever number you choose, you have to hard-code that many columns into the query, and always get that many columns of output.
For various ways to deal with a variable number of pivoted coolumns, see the following thread:
PL/SQL
This question actually doesn't have anything to do with SQL*Plus; it's strictly a SQL question, and SQL questions are best posted on the "SQL and PL/SQL" forum:
PL/SQL
If you're not sure whether a question is more of a SQL question or a SQL*Plus question, then post it on the SQL forum. Many more people pay attention to that forum than to this one. -
Need help with query join...
Hi all, i have the below query, it has too many where clauses and want to seperate it into joins perhaps, how can i do this please suggest some syntax.
Thanks,
Alex
CODE:
“select surname,award.name as award_name,module.name as module_name,attemptno as attempt_no from student,award,studentaward,module,studentenrollment where studentenrollment.attemptno = 2 and studentenrollment.studentid = student.studentid and studentenrollment.moduleid = module.moduleid and studentaward.studentid = student.studentid and studentaward.awardid = award.awardid”select surname,award.name as award_name,module.name as module_name,attemptno as attempt_no
from student
join studentaward on studentaward.studentid = student.studentid
join award on studentaward.awardid = award.awardid
join studentenrollment on studentenrollment.studentid = student.studentid
join module on studentenrollment.moduleid = module.moduleid
where studentenrollment.attemptno = 2
Maybe you are looking for
-
I try to run my first smart sync application from the smart sync tutorial on the mdk , but when I try to sync with the mi server I get "FieldValue cannot be null" message on the mi client trace . I use the merep_contact_getlist bapi wrapper that come
-
Hi all, I've got a problem (ya, another :P). I made a JFrame with a JPanel into it. But when i pressed a button, the ContentPane clears and the JPanel get a new content. But the problem is: When i pressed the button, it works. Well, i have to resize
-
I want you to know that after years of recommending Firefox to all my online learning students and everyone else for that matter I have had to stop supporting firefox because your stupid version numbers just made my courses inaccessible on firefox br
-
ISA / E-commerce Installation
Hi, We have to install ISA / E-commerce Installation on CRM 2007 server. I have checked the building blocks on help.sap.com but not getting the relavant buliding block. Can anyone provide me correct configuration guide for this activity. Thanks in
-
Could someone please point me to an 'easy to follow' tutorial on how to upload a website? I'm having trouble understanding the GoLive Help. Thanks!