Help with joining two queries
Hi
We recently inherited a database and we are re-wrting some queries. The first is
SELECT gu.GEOGRAPHIC_UNIT_ID, gu.GEOGRAPHIC_UNIT_DESC, aggDataC.DATA as Capacity, aggDataP.DATA as Production
FROM GEOGRAPHIC_UNIT_RELATIONSHIP gur, GEOGRAPHIC_UNIT
gu, AGGREGATED_DATA aggDataC, AGGREGATED_DATA aggDataP
WHERE gur.PARENT_GEOGRAPHIC_UNIT_ID = :geographicUnitId AND gur.CHILD_GEOGRAPHIC_UNIT_ID = gu.GEOGRAPHIC_UNIT_ID
AND aggDataC.GEOGRAPHIC_UNIT_ID = gu.GEOGRAPHIC_UNIT_ID
AND ((:CommodityGroupId IS NULL AND
aggDataC.COMMODITY_GROUP_ID IS NULL) OR (:CommodityGroupId = aggDataC.COMMODITY_GROUP_ID))
AND ((:CommodityTypeId IS NULL AND
aggDataC.COMMODITY_TYPE_ID IS NULL) OR (:CommodityTypeId = aggDataC.COMMODITY_TYPE_ID))
AND ((:PlantTypeId IS NULL AND aggDataC.PLANT_TYPE_ID
IS NULL) OR (:PlantTypeId = aggDataC.PLANT_TYPE_ID))
AND aggDataC.ORGANISATION_ID is NULL
AND aggDataC.YEAR = :Year
AND aggDataC.STAT_TYPE_ID = (SELECT stat_type_id FROM
stat_type WHERE stat_type = 'CAP')
AND aggDataC.STAT_PERIOD_TYPE_ID = :StatPeriodTypeId
AND aggDataP.GEOGRAPHIC_UNIT_ID = gu.GEOGRAPHIC_UNIT_ID
AND ((:CommodityGroupId IS NULL AND
aggDataP.COMMODITY_GROUP_ID IS NULL) OR (:CommodityGroupId = aggDataP.COMMODITY_GROUP_ID))
AND ((:CommodityTypeId IS NULL AND
aggDataP.COMMODITY_TYPE_ID IS NULL) OR (:CommodityTypeId = aggDataP.COMMODITY_TYPE_ID))
AND ((:PlantTypeId IS NULL AND aggDataP.PLANT_TYPE_ID
IS NULL) OR (:PlantTypeId = aggDataP.PLANT_TYPE_ID))
AND aggDataP.ORGANISATION_ID is NULL
AND aggDataP.YEAR = :Year
AND aggDataP.STAT_TYPE_ID = (SELECT stat_type_id FROM
stat_type WHERE stat_type = 'PRD')
The above query returns only the geographic units that have capacity and production figures.
I want to return all other regions that have a plantypeid regardless of whether they have capacity and production data.
I tried to use outer joins but this has not worked. The database is an oracledatabase
the below query returns all the geographic regions I need
SELECT gu.GEOGRAPHIC_UNIT_ID, gu.GEOGRAPHIC_UNIT_DESC
FROM GEOGRAPHIC_UNIT_RELATIONSHIP gur, GEOGRAPHIC_UNIT gu
where
gur.PARENT_GEOGRAPHIC_UNIT_ID = :geographicUnitId
AND gur.CHILD_GEOGRAPHIC_UNIT_ID = gu.GEOGRAPHIC_UNIT_ID
ANy idea how I merge the 2 queries?
UNION
Similar Messages
-
Help with Joining two SharePoint lists using LINQ
Hi Guys,
I have found many threads with this question. Although I had one doubt. I wanted to know that while performing a Join operation on two SharePoint Lists using LINQ does the column on which we are performing the join operation need to be a Lookup column?
I was initially using CAML but since my lists does not contain lookup columns I switched to LINQ but my doubt still remains.
I would really appreciate any help from you guys and also would appreciate if I could get some examples that I could refer to.
Thank youJoins in LINQ to SharePoint 2010
How to: Query Using LINQ to SharePoint
This post is my own opinion and does not necessarily reflect the opinion or view of Slalom. -
Joining two queries with Visual Composer
Hallo,
I was working with visual composer to join two queries with the distinct operator. But on my table view, when i linked it with the distinct operator, i get only the key element customer (customer, customer_ext_key, customer_key). These are the queries that i want join:
Query 1:
Customer
Net Sales
Query 2:
Customer
Billed Quantity
What i want to see is the following result:
Customer
Net Sales
Billed Quantity
Can anybody help me with this problem?
Greeting,
Murat.Hallo,
I was working with visual composer to join two queries with the distinct operator. But on my table view, when i linked it with the distinct operator, i get only the key element customer (customer, customer_ext_key, customer_key). These are the queries that i want join:
Query 1:
Customer
Net Sales
Query 2:
Customer
Billed Quantity
What i want to see is the following result:
Customer
Net Sales
Billed Quantity
Can anybody help me with this problem?
Greeting,
Murat. -
I'm tryinng to join two queries that I made in sqlplus:
the first one is:
select dname,sum(hours) as proj_hrs
from IBL.works_on w ,IBL.project p,IBL.department d
where w.pno=p.pnumber
and p.dnum=d.dnumber
group by dname;
that output:
DNAME PROJ_HRS
Administration 115
Headquarters 25
Research 155
the second one is:
select dname,sum(hours) as emp_hrs
from IBL.works_on w,IBL.employee e,IBL.department d
where e.dno=d.dnumber
and w.essn=e.ssn
group by dname;
that output
DNAME EMP_HRS
Administration 115
Headquarters
Research 180
I'm trying to join both of them to get:
DNAME PROJ_HRS EMP_HRS
Administration 115 115
Headquarters 25
Research 155 180
Can anybody help me pleaseIf I understood you correctly, have you tried this? I did not try this, just think that it will work.
select a.dname, a.proj_hrs, b.emp_hrs from
select dname,sum(hours) as proj_hrs
from IBL.works_on w ,IBL.project p,IBL.department d
where w.pno=p.pnumber
and p.dnum=d.dnumber
group by dname
) a,
select dname,sum(hours) as emp_hrs
from IBL.works_on w,IBL.employee e,IBL.department d
where e.dno=d.dnumber
and w.essn=e.ssn
group by dname
) b
where a.dname = b.dname
You can use the NVL function to print out something special for the null values. -
I need help with controlling two .swf's from third.
Hi, thanks for reading!
I need help with controlling two .swf's from third.
I have a problem where I need to use a corporate designed
.swf in a digital signage solution, but have been told by the legal
department that it can not be modified in any way, I also can't
have the source file yada yada. I pulled the .swfs from their
website and I decompiled them to see what I was up against.
The main swf that I need to control is HCIC.swf and the
problem is it starts w/ a preloader, which after loading stops on a
frame that requires user input (button press) on a play button,
before the movie will proceed and play through.
What I have done so far is to create a container swf,
HCIC_container.swf that will act as Target for the HCIC.swf, and
allow me to send actionscript to the file I'm not allowed to
modify.
I managed to get that done with the help of someone on
another forum. It was my hope that the following script would just
start HCIC.swf at a frame past the preloader and play button, and
just play through.
var container:MovieClip = createEmptyMovieClip("container",
getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);
mcLoader.loadClip("MCIC.swf", container);
function onLoadInit(mc:MovieClip) {
mc.gotoAndPlay(14);
But unfortunately it didn't solve my problem. Because there
is a media-controller.swf, that is being loaded by HCIC.swf that
has the controls including the play button to start HCIC.swf.
Here's a link to a .zip file with all 3 .swf files, and all 3
.fla files.
http://www.axiscc.com/temp/HCIC.zip
What I need to do is automatically start the HCIC.swf file
bypassing the pre-loader and play button without editing it or the
media-controller.swf in anyway. So all the scripting needs to be
done in HCIC_container.swf.
I know this is confusing, and its difficult to explain, but
if you look at the files it should make sense.
ActionScripting is far from my strong point, so I'm
definitely over my head here.
Thanks for your help.Got my solution on another forum.
http://www.actionscript.org/forums/showthread.php3?t=146827 -
I need help with these two crashes...
PL_DHashTableOperate | GCGraphBuilder::NoteRoot(unsigned int, void*, nsCycleCollectionParticipant*)
DFusionWebPlugin@0x86b5
The first one happened a couple of days ago, a few times and not on any specific website.
The second one only happens on the site below.The second one indicates a problem with the DFusionWebPlugin that shows in your More system details list.
# D'Fusion Web Plug-In for Safari 64 bits (3.00.13774.0)
# D'Fusion Web Plug-In (3.00.13774.0)
What you posted are crash signatures.<br />
It might help if you post the actual crash IDs (bp-xxxxxxxx-xxxxxxxxx-xxxx-xxxxxxxxxxxx).<br />
You can find the IDs of the submitted crash reports on the <i>about:crashes</i> page.
See http://kb.mozillazine.org/Breakpad (Mozilla Crash Reporter) -
Joining two queries causes big performance hit
There are two queries: one with a sub query and one without
although they both return the same data, one uses a full table scan of the indexed 'trade_index' table
and thus is much slower
any Ideas why it does this?:
SQL> select count(*) from trade_index ti, counterparty_xref cx
2 where ti.CPY_SID = cx.CPY_SID and ti.TRADE_OR_ARCHIVE = 'A'
3 and cx.XREF_VALUE in (select ml.VALUE from v_mis_lists ml where ml.LIST_NAME = 'Deutsche Bank DB')
4 and cx.XREF_TYPE = 'Client RXM'
5 and ti.START_DATE < to_date('01/01/2004','DD/MM/YYYY')
6 and (ti.END_DATE >= to_date('01/01/2003','DD/MM/YYYY') or ti.END_DATE = '01-Jan-1900') ;
COUNT(*)
6195
Elapsed: 00:00:15.08
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2572 Card=1 Bytes=57)
1 0 SORT (AGGREGATE)
2 1 HASH JOIN (Cost=2572 Card=26581 Bytes=1515117)
3 2 HASH JOIN (Cost=460 Card=5619 Bytes=219141)
4 3 VIEW OF 'VW_NSO_1' (Cost=8 Card=16 Bytes=272)
5 4 SORT (UNIQUE) (Cost=8 Card=16 Bytes=960)
6 5 HASH JOIN (Cost=4 Card=16 Bytes=960)
7 6 TABLE ACCESS (BY INDEX ROWID) OF 'MIS_LISTS' (Cost=1 Card=2 Bytes=60)
8 7 INDEX (RANGE SCAN) OF 'MISL_NAT_UK' (UNIQUE) (Cost=2 Card=2)
9 6 TABLE ACCESS (FULL) OF 'MIS_LIST_VALUES' (Cost=2 Card=817 Bytes=24510)
10 3 TABLE ACCESS (FULL) OF 'COUNTERPARTY_XREF' (Cost=451 Card=35116 Bytes=772552)
11 2 TABLE ACCESS (FULL) OF 'TRADE_INDEX' (Cost=2056 Card=286928 Bytes=5164704)
SQL> select ml.VALUE from v_mis_lists ml where ml.LIST_NAME = 'Deutsche Bank DB';
VALUE
B49540
B60010
Elapsed: 00:00:00.00
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 NESTED LOOPS
2 1 TABLE ACCESS (BY INDEX ROWID) OF 'MIS_LISTS'
3 2 INDEX (RANGE SCAN) OF 'MISL_NAT_UK' (UNIQUE)
4 1 INDEX (RANGE SCAN) OF 'MISLV_PK' (UNIQUE)
SQL> select count(*) from trade_index ti, counterparty_xref cx
2 where ti.CPY_SID = cx.CPY_SID and ti.TRADE_OR_ARCHIVE = 'A'
3 and cx.XREF_VALUE in ('B49540','B60010')
4 and cx.XREF_TYPE = 'Client RXM'
5 and ti.START_DATE < to_date('01/01/2004','DD/MM/YYYY')
6 and (ti.END_DATE >= to_date('01/01/2003','DD/MM/YYYY') or ti.END_DATE = '01-Jan-1900') ;
COUNT(*)
6195
Elapsed: 00:00:02.06
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=532 Card=1 Bytes=40)
1 0 SORT (AGGREGATE)
2 1 NESTED LOOPS (Cost=532 Card=41 Bytes=1640)
3 2 TABLE ACCESS (FULL) OF 'COUNTERPARTY_XREF' (Cost=451 Card=1 Bytes=22)
4 2 TABLE ACCESS (BY INDEX ROWID) OF 'TRADE_INDEX' (Cost=81 Card=286928 Bytes=5164704)
5 4 INDEX (RANGE SCAN) OF 'CPY_SID_IDX' (NON-UNIQUE) (Cost=2 Card=286928)
What I dont understand is that:
cx.XREF_VALUE in (select ml.VALUE from v_mis_lists ml where ml.LIST_NAME = 'Deutsche Bank DB')
and
cx.XREF_VALUE in ('B49540','B60010')
are essentially the same thing
(ie the subquery returns the values I have used)
but the optimizer uses a totally different (slower) method to execute the rest of the former query?
Many thanks
IanHi,
Here is with join and not using the view: still have full table scan of large table trade_index
SQL> select count(*) from mis_lists ml, mis_list_values mlv, counterparty_xref cx, trade_index ti
2 where ti.CPY_SID = cx.CPY_SID and ti.TRADE_OR_ARCHIVE = 'A'
3 and cx.XREF_VALUE = mlv.VALUE
4 and mlv.MISL_SID = ml.MISL_SID
5 and ml.LIST_NAME = 'Deutsche Bank DB'
6 and cx.XREF_TYPE = 'Client RXM'
7 and ti.START_DATE < to_date('01/01/2004','DD/MM/YYYY')
8 and (ti.END_DATE >= to_date('01/01/2003','DD/MM/YYYY') or ti.END_DATE = '01-Jan-1900') ;
COUNT(*)
6195
Elapsed: 00:00:12.08
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2602 Card=1 Bytes=10
0)
1 0 SORT (AGGREGATE)
2 1 HASH JOIN (Cost=2602 Card=26581 Bytes=2658100)
3 2 HASH JOIN (Cost=456 Card=5619 Bytes=460758)
4 3 HASH JOIN (Cost=4 Card=16 Bytes=960)
5 4 TABLE ACCESS (BY INDEX ROWID) OF 'MIS_LISTS' (Cost1 Card=2 Bytes=60)
6 5 INDEX (RANGE SCAN) OF 'MISL_NAT_UK' (UNIQUE) (Cost=2 Card=2)
7 4 TABLE ACCESS (FULL) OF 'MIS_LIST_VALUES' (Cost=2 Card=817 Bytes=24510)
8 3 TABLE ACCESS (FULL) OF 'COUNTERPARTY_XREF' (Cost=451Card=35116 Bytes=772552)
9 2 TABLE ACCESS (FULL) OF 'TRADE_INDEX' (Cost=2056 Card=286928 Bytes=5164704)
Statistics
0 recursive calls
47 db block gets
16519 consistent gets
4981 physical reads
0 redo size
205 bytes sent via SQL*Net to client
622 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
Thanks for you help,
Ian -
Newbie: help with join in a select query
Hi: I need some help with creating a select statement.
I have two tables t1 (fields: id, time, cost, t2id) and t2 (fields: id, time, cost). t2id from t1 is the primary key in t2. I want a single select statement to list all time and cost from both t1 and t2. I think I need to use join but can't seem to figure it out even after going through some tutorials.
Thanks in advance.
Rayt1 has following records
pkid, time, cost,product
1,123456,34,801
2,123457,20,802
3,345678,40,801
t2 has the following records
id,productid,time,cost
1,801,4356789,12
2,801,4356790,1
3,802,9845679,100
4,801,9345614,12
I want a query that will print following from t1 (time and cost for records that have product=801)
123456,34
345678,40
followed by following from t2 (time and cost for records that have productid=801)
4356789,12
4356790,1
9345614,12
Is this possible?
Thanks
ray -
Hi,
I am not sure if I am doing something wrong here, but would appreciate if someone point out my mistake.
I have two table item and item_status
item_status do not contain all the items but only the ones which have specific status
Question(1):
select count(*) from item
and
select count(*) from item left join item_status on item.itemid = item_status.item_id
Result of these two queries dont match. Can you'll plz help me understand it.
Question(2):
I want count of items from table item by location (location is another field in table item) but I want to exclude items which have status lost in the item_status table.
This is the query I used:
select location, count(*) from item left join item_status on item.itemid = item_status.item_id where item_status.status = 'lost'
is this the correct way, coz when I tried the figures where way to low,
Thanks,
RajaHi, Raja,
Raja Gopalan wrote:
Hi,
I am not sure if I am doing something wrong here, but would appreciate if someone point out my mistake.
I have two table item and item_status
item_status do not contain all the items but only the ones which have specific status
Question(1):
select count(*) from item
and
select count(*) from item left join item_status on item.itemid = item_status.item_id
Result of these two queries dont match. Can you'll plz help me understand it.If there can be many rows in item_status that all match the same row in item, then the 2nd query will have a higher COUNT than the first.
If you'd post your tables, I could show you in detail.
Since you didn't I'll use tables from the scott schema.
SELECT d.deptno
FROM scott.dept d;produces 4 rows:
. DEPTNO
10
20
30
40Only 3 of these rows have a match in the mep table, but the ones that match have many matches.
SELECT d.deptno
, e.ename
FROM scott.dept d
LEFT OUTER JOIN scott.emp e ON d.deptno = e.deptno;produces 15 rows
. DEPTNO ENAME
20 SMITH
30 ALLEN
30 WARD
20 JONES
30 MARTIN
30 BLAKE
10 CLARK
20 SCOTT
10 KING
30 TURNER
20 ADAMS
30 JAMES
20 FORD
10 MILLER
401 row for each row in emp that has a match in dept (that is all 14 rows in emp) plus 1 row for every row in dept that does not have a match in emp (1 row).
Question(2):
I want count of items from table item by location (location is another field in table item) but I want to exclude items which have status lost in the item_status table.
This is the query I used:
select location, count(*) from item left join item_status on item.itemid = item_status.item_id where item_status.status = 'lost'
is this the correct way, coz when I tried the figures where way to low,If you want a count by location, then you should say "GROUP BY location".
You probably need a sub-query to check for 'lost'. Without seeing your tables and data, I can't be sure.
Maybe something like
SELECT location
, COUNT (*)
FROM item
WHERE itemid NOT IN ( -- Begin subquery to find bad item_ids
SELECT item_id
FROM item_status
WHERE status = 'lost'
) -- End subquery to find bad item_ids
GROUP BY location
; -
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
_1st query_
select
(CASE WHEN SUBSTR(R1.RA_NO,1,3)= 'NRA' THEN 'Damansara Uptown One Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'ORA' THEN 'Damansara Uptown Two Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'VRA' THEN 'Damansara Uptown Realty Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'URA' THEN 'Uptown Elite Sdn. Bhd.'
when SUBSTR(R1.RA_NO,1,3)= 'WRZ' THEN 'U5 Management Corporation Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,2)= 'FR' THEN 'See Hoy Chan Facilities Management Sdn.Bhd.' END) Landlord
,TO_CHAR(C1.COLL_DTE,'RRRRMM') MONTH1
,SUM(C2.TRN_AMT) UPTO_31
, SUM(CASE WHEN to_char(C1.COLL_dte) BETWEEN to_date(:P_FROM_DATE,'dd.mm.yyyy') AND '16-'||to_date(:P_TO_DATE,'dd.mm.yyyy') THEN C2.TRN_AMT END) UPTO_15
from ra1 R1, COLLECT1 C1 , COLLECT2 C2
where
(to_char(C1.COLL_dte) between to_date(:P_FROM_DATE,'dd.mm.yyyy') AND to_date(:P_TO_DATE,'dd.mm.yyyy'))
and (SUBSTR(R1.RA_NO,1,2)= 'FR' or SUBSTR(R1.RA_NO,1,3) in ('NRA' ,'ORA','VRA','URA','WRZ'))
AND R1.RA_NO = C2.INV_NO
AND C2.COLL_NO = C1.COLL_NO
GROUP BY
(CASE WHEN SUBSTR(R1.RA_NO,1,3)= 'NRA' THEN 'Damansara Uptown One Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'ORA' THEN 'Damansara Uptown Two Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'VRA' THEN 'Damansara Uptown Realty Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'URA' THEN 'Uptown Elite Sdn. Bhd.'
when SUBSTR(R1.RA_NO,1,3)= 'WRZ' THEN 'U5 Management Corporation Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,2)= 'FR' THEN 'See Hoy Chan Facilities Management Sdn.Bhd.' END)
,TO_CHAR(C1.COLL_DTE,'RRRRMM')
_2query_
select sum(decode(substr(ra_no,1,7),'NRA'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) NRA
,sum(decode(substr(ra_no,1,7),'VRA'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) VRA
,sum(decode(substr(ra_no,1,7),'ORA'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) ORA
,sum(decode(substr(ra_no,1,7),'FR'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) FR
,sum(decode(substr(ra_no,1,7),'WRZ'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) WRZ
,sum(decode(substr(ra_no,1,7),'URA'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) URA
from RA1
above are the two queries i need to join these two queries by naming the second query column name as total .1st query output is ----------
LOCATION MONTH1 UPTO_31 UPTO_15
U5 Management Corporation Sdn. Bhd. 201001 15250 8900
Uptown Elite Sdn. Bhd. 201001 3000 1500
See Hoy Chan Facilities Management Sdn.Bhd. 201001 917115.45 584876.5
Damansara Uptown Two Sdn. Bhd. 201001 757277.45 495362.95
Damansara Uptown One Sdn. Bhd. 201001 881558.65 404872.45
Damansara Uptown Realty Sdn. Bhd. 201001 321675.8 150508.6
2nd query output is -------
NRA ORA VRA URA WRZ FR
2323.31 95945 34367.8 34267 4343 343
Now what i need is
LOCATION MONTH1 UPTO_31 UPTO_15 TOTAL
U5 Management Corporation Sdn. Bhd. 201001 15250 8900 2323.31
Uptown Elite Sdn. Bhd. 201001 3000 1500 95945
See Hoy Chan Facilities Management Sdn.Bhd. 201001 917115.45 584876.5 34367.8
Damansara Uptown Two Sdn. Bhd. 201001 757277.45 495362.95 34267
Damansara Uptown One Sdn. Bhd. 201001 881558.65 404872.45 4343
Damansara Uptown Realty Sdn. Bhd. 201001 321675.8 150508.6 343above is the clear picture what i need , i don't know how to do it please help me
Edited by: user9093689 on Feb 21, 2010 8:06 PM -
Help with Joining a few tables
I need a help using JOINS. I plan to create ONE VIEW by bringing in all fields from First and Second table and a few chosen columns from Third, Fourth and Fifth tables. I have put to together below select statement which appears to be working syntax-wise but not efficient and may have dupes.
Table1 - RPT_APRL_PRODUCT with key field KEY_MATERIAL (KEY_MATERIAL = DIVISION||PLAN_CTRY||MKT_TYP_ID||MATERIAL)
Table 2 - RPT_FWEQ_PRODUCT with key field KEY_MATERIAL (KEY_MATERIAL = DIVISION||PLAN_CTRY||MATERIAL)
Table 3 - NSC_PROD_CIMG has a Key Field = MATERIAL_NBR
Table 4- STAGE#EMEA_NSAP.NSC_PROD_REG_CIMG has the Key field MATERIAL_NBR, REG_ID
Table 5 - STAGE#EMEA_NSAP.NSC_PROD_REG_CYC_CIMG has Key Fields MATERIAL_NBR, REG_ID, CYC_ID and ORGVERSIONID
Columns needed from Table 3 -- B.DIVISION, B.DIVISIONNAME, B.SUBLABEL, B.SUBLABELNAME and B.DEVELOPMENTREGION.
Columns needed from Table 4 --- C.GLOBALSOURCEINDICATOR
Columns needed from Table 5--- D.CARRYOVERFLAG
SELECT statement:
SELECT /*+ parallel (a,5) parallel (NET,5) */
a.key_material,
a.mkt_typ_id,
a.region_id,
CASE
WHEN a.region_id = '3' THEN 'USA'
WHEN a.region_id = '4' THEN 'EMEA'
WHEN a.region_id = '7' THEN 'CANADA'
END AS region_desc,
a.mkt_reg_cd,
CASE
WHEN a.mkt_reg_cd = '01' THEN 'USA'
WHEN a.mkt_reg_cd = '02' THEN 'EMEA'
WHEN a.mkt_reg_cd = '05' THEN 'AMER'
END AS mkt_reg_desc,
a.cat_bus_cd1,
a.cat_bus_desc1,
a.cat_bus_cd2,
a.cat_bus_desc2,
a.cat_bus_cd3,
a.cat_bus_desc3,
a.cat_bus_cd4,
a.cat_bus_desc4,
a.mkstr_cd,
a.mkt_clsfn_desc,
a.mkt_clsfn_cd1,
a.mkt_clsfn1_desc,
a.mkt_clsfn_cd2,
a.mkt_clsfn2_desc,
a.mkt_clsfn_cd3,
a.mkt_clsfn3_desc,
a.exp_sty_ind,
a.silh_cd,
a.silh_desc,
a.whlsl_prc,
0,
NULL,
NULL,
NULL,
NULL,
NULL,
a.gender_age_class_id,
a.gender_age_desc,
a.sports_activity_class_id,
a.sports_act_cls_desc,
a.gblcatsummcode,
a.gblcatsummdesc,
a.gblcatcorefocuscode,
a.gblcatcorefocusdesc,
a.segment,
a.segmentname,
a.l4l_fl,
NET.DIVISION,
NET.DIVISIONNAME,
NET.SUBLABEL,
NET.SUBLABELNAME,
NET.DEVELOPMENTREGION,
NULL,
NULL,
NULL,
NET.globalsourceindicator,
NET.CARRYOVERFLAG,
a.zz_chng_tmst,
a.zz_update_tmst,
a.zz_insert_tmst
FROM RPT_APRL_PRODUCT A,
(SELECT
APRL.DIVISION||APRL.PLAN_CTRY||APRL.MKT_TYP_ID||APRL.MATERIAL ; AS KEY_MATERIAL,
B.DIVISION,
B.DIVISIONNAME,
B.SUBLABEL,
B.SUBLABELNAME,
B.DEVELOPMENTREGION,
C.GLOBALSOURCEINDICATOR,
D.CARRYOVERFLAG
from RPT_APRL_PRODUCTAPRL,
NSC_PROD_CIMG B,
NSC_PROD_REG_CIMG C,
NSC_PROD_REG_CYC_CIMG D
where APRL.MATERIAL = B.MATERIAL_NBR AND
APRL.MATERIAL = C.MATERIAL_NBR AND
APRL.MATERIAL = D.MATERIAL_NBR AND
C.REG_ID = D.REG_ID) NET
WHERE A.KEY_MATERIAL = NET.KEY_MATERIAL(+)
Thanks for help in advance.I have 4 tables and these are some sample data for
RPT_APRL_PRODUCT - Key Field = KEY_MATERIAL (this is a combination of plan_ctry,division,mkt_typ_id and material)
Sample data
KEY_MATERIAL PLAN_CTRY DIVISION MKT_TYP_ID MATERIAL
10PART1136353-010 PART 10 1 136353-010
10AMER1136353-010 AMER 10 1 136353-010
10USA1136353-010 USA 10 1 136353-010
10CANA1136353-010 CANA 10 1 136353-010
10PART1137508-050 PART 10 1 137508-050
10AMER1137508-050 AMER 10 1 137508-050
10CANA1137508-050 CANA 10 1 137508-050
10USA1137508-050 USA 10 1 137508-050
10PART1137617-050 PART 10 1 137617-050
10AMER1137617-050 AMER 10 1 137617-050nsc_prod_reg_cimg - keys (material_nbr and reg_id)
MATERIAL REG_ID GLOBALSOURCEINDICATOR
136353-010 3 G
136353-010 6 G
136353-010 7
137508-050 3
137508-050 6 G
137508-050 7
137508-050 46 G
137617-050 3
137617-050 6
137617-050 46 nsc_prod_reg_cyc_cimg - key is material_nbr, cyc_id, reg_id and orgversion_id
MATERIAL_NBR CYC_ID orgversion_id reg_ID CARRYOVERFLAG
136353-010 101 1 3 Y
136353-010 101 1 6 Y
136353-010 101 1 7 N
137508-050 202 1 3 Y
137508-050 202 1 6 N
137508-050 202 1 7
137617-050 205 1 3
137617-050 205 1 6
185204-402 181 1 8
185204-402 182 1 8 nsc_prod_cimg - key is material_nbr
MATERIAL_NBR SUBLABEL SUBLABELNAME
136353-010
137508-050 GD Good
137617-050
185204-402
185204-402
185204-402 BE Better
185204-402
185204-402
185204-402 CO Core
185204-402 BS BestWhat I intend to do, is to create one view by joining these four tables. The columns key_material, plan_ctry, division and MKT_TYP_ID come from RPT_APRL_PRODUCT. I need to join these tables in such a way that I bring in the other 1 or 2 columns each from the 3 tables as described above. The result should have a unique key_material and have the other column data in the view as well.
Result should be all the columns described above, something like this below...
KEY_MATERIAL PLAN_CTRY DIVISION MKT_TYP_ID MATERIAL SUBLABELNAME CARRYover_FL
10PART1136353-010 PART 10 1 136353-010
10AMER1136353-010 AMER 10 1 136353-010 -
Help with Merging Two Accounts....
Hi,
We ended up with two my Best Buy accounts.
I called up and talked with someone, who said they would merge the accounts....
A few hours later, when I logged in, the website said I had two accounts and to choose one to view.
That lasted for about 4 days,
Then, the website didn't ask anymore and just logged into one account ... which I thought meant the merge had occured.
HOWEVER, none of the purchases on the"other" account are on the primary account, which was the point of teHi scXenon,
I used the email address you registered with the forum to review your information, and I do see that you currently have two active My Best Buy™ accounts. If the primary information shared between the two accounts matches, then we should have no problem merging them. That process would involve closing one account, and then moving any unused points/certificates from the closed account to the active primary account.
I do see that you have an open case with our Account Maintenance department and I trust that they will be able to help successfully merge your accounts; however, I am going to send you a private message to see if there is anything I can help with. To check your private messages, you would want to login to the forum and click on the yellow envelope icon located at the top of the page.
Merging My Best Buy™ Accounts
Thank you for posting!
Derek|Social Media Specialist | Best Buy® Corporate
Private Message -
Help with implementing two different programs
I need help with a couple of Java programs that I downloaded. I hope someone can help me. They work great if they're on their own, but if they are both on the same page, the 2nd one works, and the 1st one stops working. I'm pretty new to Java, so I don't know how to debug it too well.. Here's the 1st program:
Conveyor belt slideshow script-
? Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit dynamicdrive.com
//Specify the slider's width (in pixels)
var sliderwidth="250px"
//Specify the slider's height
var sliderheight="19px"
//Specify the slider's slide speed (larger is faster 1-10)
var slidespeed=2
//configure background color:
slidebgcolor=""
//Specify the slider's images
var leftrightslide=new Array()
var finalslide=''
leftrightslide[0]='<img src="images/movingwords.gif">'
////NO NEED TO EDIT BELOW THIS LINE////////////
var copyspeed=slidespeed
leftrightslide='<nobr>'+leftrightslide.join(" ")+'</nobr>'
var iedom=document.all||document.getElementById
if (iedom)
//Next line edited for readability
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">
'+leftrightslide+'</span>')
var actualwidth=''
var cross_slide, ns_slide
function fillup(){
if (iedom){
cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
cross_slide2.style.left=actualwidth+20+"px"
else if (document.layers){
ns_slide=document.ns_slidemenu.document.ns_slidemenu2
ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
ns_slide.document.write(leftrightslide)
ns_slide.document.close()
actualwidth=ns_slide.document.width
ns_slide2.left=actualwidth+20
ns_slide2.document.write(leftrightslide)
ns_slide2.document.close()
lefttime=setInterval("slideleft()",30)
window.onload=fillup
function slideleft(){
if (iedom){
if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
else
cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+30+"px"
if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
else
cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+30+"px"
else if (document.layers){
if (ns_slide.left>(actualwidth*(-1)+8))
ns_slide.left-=copyspeed
else
ns_slide.left=ns_slide2.left+actualwidth+30
if (ns_slide2.left>(actualwidth*(-1)+8))
ns_slide2.left-=copyspeed
else
ns_slide2.left=ns_slide.left+actualwidth+30
if (iedom||document.layers){
with (document){
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
if (iedom){
write('<div style="position:relative;width:'+sliderwidth+';height:'+sliderheight+';overflow:hidden">')
//Next line edited for readability
write('<div style="position:absolute;width:'+sliderwidth+';height:'+sliderheight+';
background-color:'+slidebgcolor+'" onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed">')
write('<div id="test2" style="position:absolute;left:0px;top:0px"></div>')
write('<div id="test3" style="position:absolute;left:-1000px;top:0px"></div>')
write('</div></div>')
else if (document.layers){
write('<ilayer width='+sliderwidth+' height='+sliderheight+' name="ns_slidemenu" bgColor='+slidebgcolor+'>')
write('<layer name="ns_slidemenu2" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
write('<layer name="ns_slidemenu3" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
write('</ilayer>')
document.write('</td></table>')
}Here's the 2nd program:
//Fade-in image slideshow- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use
var slideshow_width='305px' //SET IMAGE WIDTH
var slideshow_height='152px' //SET IMAGE HEIGHT
var pause=5000 //SET PAUSE BETWEEN SLIDE (3000=3 seconds)
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]="images/Computer Retail Store.jpg"
fadeimages[1]="images/Computer S&S ad.jpg"
fadeimages[2]="images/Computer S&S ad 2.jpg"
fadeimages[3]="images/Phone S&S ad.jpg"
////NO need to edit beyond here/////////////
var preloadedimages=new Array()
for (p=0;p<fadeimages.length;p++){
preloadedimages[p]=new Image()
preloadedimages[p].src=fadeimages[p]
var ie4=document.all
var dom=document.getElementById
if (ie4||dom)
//Next line edited for readability
document.write('<div style="position:relative;width:'+slideshow_width+';height:'+slideshow_height+';overflow:hidden">
<div id="canvas0" style="position:absolute;width:'+slideshow_width+';height:'+slideshow_height+';top:0;left:0;filter:
alpha(opacity=10);-moz-opacity:10"></div><div id="canvas1" style="position:absolute;width:'+slideshow_width+';
height:'+slideshow_height+';top:0;left:0;filter:
alpha(opacity=10);-moz-opacity:10"></div></div>')
else
document.write('<img name="defaultslide" src="'+fadeimages[0]+'">')
var curpos=10
var degree=10
var curcanvas="canvas0"
var curimageindex=0
var nextimageindex=1
function fadepic(){
if (curpos<100){
curpos+=10
if (tempobj.filters)
tempobj.filters.alpha.opacity=curpos
else if (tempobj.style.MozOpacity)
tempobj.style.MozOpacity=curpos/100
else{
clearInterval(dropslide)
nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1"
tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
tempobj.innerHTML='<img src="'+fadeimages[nextimageindex]+'">'
nextimageindex=(nextimageindex<fadeimages.length-1)? nextimageindex+1 : 0
setTimeout("rotateimage()",pause)
function rotateimage(){
if (ie4||dom){
resetit(curcanvas)
var crossobj=tempobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
crossobj.style.zIndex++
var temp='setInterval("fadepic()",50)'
dropslide=eval(temp)
curcanvas=(curcanvas=="canvas0")? "canvas1" : "canvas0"
else
document.images.defaultslide.src=fadeimages[curimageindex]
curimageindex=(curimageindex<fadeimages.length-1)? curimageindex+1 : 0
function resetit(what){
curpos=10
var crossobj=ie4? eval("document.all."+what) : document.getElementById(what)
if (crossobj.filters)
crossobj.filters.alpha.opacity=curpos
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=curpos/100
function startit(){
var crossobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
crossobj.innerHTML='<img src="'+fadeimages[curimageindex]+'">'
rotateimage()
if (ie4||dom)
window.onload=startit
else
setInterval("rotateimage()",pause)Like I said, if the 2nd program is put the same page with the 1st, the 1st program stops working. Any ideas? I would really like to implement both of these programs.The code you post is javascript, NOT java ! ... but either way, maybe the scripts have variables in conflict, so if you pack each piece of code in diferent functions and then you call the functions it may work.
-
I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
[ABCTABLE]
ABCORDER
ABCPART
ABCSERIAL
ABCDATE
[ZYXTABLE]
XYZORDER
XYZPART
XYZSERIAL
XYZDATE1
XYZDATE2Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
on this computer. There are no "Null" fields in either of the tables.
This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
[MSORDR]
MSORDER
MSPART
MSSERIAL
MSOPNDATE
11111111
4444444
55555
2/4/2015
22222222
6666666
11111
1/6/2015
33333333
6666666
11111
3/5/2015
This table has one order for every part number and every serial number.
[GLORDR]
GLORDER
GLPART
GLSERIAL
GLSTARTDATE
GLENDDATE
ABC11111
444444
55555
1/2/2015
4/4/2015
ABC22222
666666
11111
1/5/2015
4/10/2015
AAA11111
555555
22222
3/2/2015
4/10/2015
Post Query table
GLORDER
MSORDER
GLSTARTDATE
GLENDDATE
MSOPNDATE
ABC11111
11111111
1/2/2015
4/4/2015
2/4/2015
ABC22222
22222222
1/5/2015
4/10/2015
1/6/2015
ABC22222
33333333
1/5/2015
4/10/2015
3/5/2015
This is the SQL minus the between date join.
SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART); -
Need help with the update queries - joining three tables -
We have three tables shown below, each with millions of rows;
And need some updates in here;
T_CHECK->TOTAL_AMT_PAID should be equal to
aim00.t_chck_clm_xref->amt_paid + aim01.t_chck_clm_xref->amt_paid;
Some CHECK_SAK values exist in aim00.t_chck_clm_xref and some exist in aim01.t_chck_clm_xref;
We tried to update using the queries within PL/SQL shown below:
Is there a way to make these more effecient?
SQL> desc aim.t_check;
Name Null? Type
CHECK_SAK NOT NULL NUMBER(9)
TOTAL_AMT_PAID NOT NULL NUMBER(11,2)
DTE_ISSUE NOT NULL NUMBER(8)
SQL> desc aim00.t_chck_clm_xref
Name Null? Type
CHECK_SAK NOT NULL NUMBER(9)
AMT_PAID NOT NULL NUMBER(10,2)
SQL> desc aim01.t_chck_clm_xref
Name Null? Type
CHECK_SAK NOT NULL NUMBER(9)
AMT_PAID NOT NULL NUMBER(10,2)
create or replace PROCEDURE CHECKSUPDATE IS
cursor my_cursor is
select /*+ DRIVING_SITE(t_check) INDEX(t_check) */
tot, mid, aim.t_check.total_amt_paid from
(select sum(aim01.t_chck_clm_xref.amt_paid) tot,
aim01.t_chck_clm_xref.check_sak mid from aim01.t_chck_clm_xref
where
not exists (select 'x' from aim00.t_chck_clm_xref
where aim01.t_chck_clm_xref.check_sak = aim00.t_chck_clm_xref.check_sak
group by aim01.t_chck_clm_xref.check_sak) TABLE1, aim.t_check
where aim.t_check.check_sak = table1.mid
and aim.t_check.total_amt_paid <> tot;
my_count NUMBER;
BEGIN
my_count:=0;
for my_pos in my_cursor loop
update aim.t_check a set total_amt_paid=my_pos.tot
where a.check_sak=my_pos.mid;
my_count:=my_count+1;
if (mod(my_count,1000)=0) THEN
commit;
end if;
end loop;
commit;
END CHECKSUPDATE;>
SQL> desc t_check;
Name Null? Type
CHECK_SAK NUMBER(9)
TOTAL_AMT_PAID NUMBER(11,2)
DTE_ISSUE NUMBER(8)
SQL> desc t_chck_clm_xref
Name Null? Type
CHECK_SAK NUMBER(9)
AMT_PAID NUMBER(10,2)
SQL> desc t_test
Name Null? Type
CHECK_SAK NUMBER(9)
AMT_PAID NUMBER(10,2)
select check_sak, sum(amt_paid)
from (
select check_sak, amt_paid from t_chck_clm_xref
union all
select check_sak, amt_paid from t_test
group by check_sak;and use this query in an UPDATE statement or a MERGE statement, as Tubby suggested, against the T_CHECK table.
isotope
Maybe you are looking for
-
Error c000021a : {fatal system error} while booting laptop M30 series
I get the following error when starting my laptop. "Stop: c00021a {fatal system error} The windows logon process system process terminated unexpectedly with a status of 0x00000080 (0x00000000 0x00000000) The system has been shut down" I have recovery
-
Updating 2013 SP1 to CU8 Error - Set-SharedConfigDC Fails
I have two 2012 servers running Exchange 2013 SP1. They are both multi-role servers and are members of a DAG and are also load-balanced behind a Citrix Netscaler. I was ready to begin moving my mailboxes from 2010 to 2013 when I ran into a problem. I
-
Can I use InDesign's Data Merge for more than just address labels?
I am a Graphic Designing working on a new science exhibition in Melbourne, Australia. I'm trying to streamline the way we import our label content into InDesign (currently cut and paste from Word which is slow and leaves room for error). I've been go
-
Can some one tell me the SAP USERS ROLE TABLE I Will assign point to any input. Balance Roll forward Change Vendor Line Items Change Parked Vendor Document Change/ Reverse Vendor Invoice Check Processing Clear Accounts Payable Items Display
-
Error in function call BAPI_0050_CREATE. Create FM Budgeting Entry document
Hi guys, I've got runtime error in BAPI-function call BAPI_0050_CREATE for create\release budgeting entry document: "Number range 01 not found for object BULI_DOCNR in fiscal year 2007" Function parameters below: CALL FUNCTION 'BAPI_0050_CREATE' EXPO