Cross join returns 0 records
Q1.
My cross-join return 0 records if any of the table, either table A or table B, is empty. Please confirm.
Q2.
I need to generate a salary slip.
my first query is:
select sh.headname Allownces, ee.amount Amount from hrm_employeeentitlement ee
inner join hrm_salaryhead sh on ee.hrm_salaryhead_id = sh.hrm_salaryhead_id
where ee.hrm_salaryheadtype_id = 1000000
my second query is:
select sh.headname Deductions, ee.amount Amount, ee.balance Balance from hrm_employeeentitlement ee
inner join hrm_salaryhead sh on ee.hrm_salaryhead_id = sh.hrm_salaryhead_id
where ee.hrm_salaryheadtype_id = 1000001
now i have taken a cross join of both
select vallownces.Allownces, vallownces.Amount, vdeductions.Deductions, vdeductions.Amount, vdeductions.Balance
from
select sh.headname Allownces, ee.amount Amount from hrm_employeeentitlement ee
inner join hrm_salaryhead sh on ee.hrm_salaryhead_id = sh.hrm_salaryhead_id
where ee.hrm_salaryheadtype_id = 1000000
) vallownces cross join
select sh.headname Deductions, ee.amount Amount, ee.balance Balance from hrm_employeeentitlement ee
inner join hrm_salaryhead sh on ee.hrm_salaryhead_id = sh.hrm_salaryhead_id
where ee.hrm_salaryheadtype_id = 1000001
returns 0 records because second sub-query is empty.
Q 3:
any alternate please ?
With full-outer-join (9 records)
with tab as
select 'Special Pay 6' HEADNAME, '0' AMOUNT, '0' BALANCE, '922394' EMPCODE, '1000000' HRM_SALARYHEADTYPE_ID from dual UNION ALL
select 'Utility Bill' HEADNAME, '600' AMOUNT, '0' BALANCE, '922394' EMPCODE, '1000000' HRM_SALARYHEADTYPE_ID from dual UNION ALL
select 'Tea Coupen' HEADNAME, '253' AMOUNT, '0' BALANCE, '922394' EMPCODE, '1000000' HRM_SALARYHEADTYPE_ID from dual UNION ALL
select 'Co-Operative Society' HEADNAME, '50' AMOUNT, '0' BALANCE, '922394' EMPCODE, '1000001' HRM_SALARYHEADTYPE_ID from dual UNION ALL
select 'D E C E Fund' HEADNAME, '25' AMOUNT, '0' BALANCE, '922394' EMPCODE, '1000001' HRM_SALARYHEADTYPE_ID from dual UNION ALL
select 'Aid On Death' HEADNAME, '50' AMOUNT, '0' BALANCE, '922394' EMPCODE, '1000001' HRM_SALARYHEADTYPE_ID from dual
select t1.Allownces, t1.AMOUNT, t1.BALANCE, t2.Deductions, t2.AMOUNT, t2.BALANCE from
select HEADNAME Allownces, AMOUNT, BALANCE, EMPCODE, 'donnot-match' x from tab where HRM_SALARYHEADTYPE_ID = 1000000
) t1
full outer join
select HEADNAME Deductions, AMOUNT, BALANCE, EMPCODE, 'alright' x from tab where HRM_SALARYHEADTYPE_ID = 1000001
) t2 ON t1.empcode = t2.empcode
With full-outer-join but on irrelevant column as i said ... (all the 6 records)
with tab as
select 'Special Pay 6' HEADNAME, '0' AMOUNT, '0' BALANCE, '922394' EMPCODE, '1000000' HRM_SALARYHEADTYPE_ID from dual UNION ALL
select 'Utility Bill' HEADNAME, '600' AMOUNT, '0' BALANCE, '922394' EMPCODE, '1000000' HRM_SALARYHEADTYPE_ID from dual UNION ALL
select 'Tea Coupen' HEADNAME, '253' AMOUNT, '0' BALANCE, '922394' EMPCODE, '1000000' HRM_SALARYHEADTYPE_ID from dual UNION ALL
select 'Co-Operative Society' HEADNAME, '50' AMOUNT, '0' BALANCE, '922394' EMPCODE, '1000001' HRM_SALARYHEADTYPE_ID from dual UNION ALL
select 'D E C E Fund' HEADNAME, '25' AMOUNT, '0' BALANCE, '922394' EMPCODE, '1000001' HRM_SALARYHEADTYPE_ID from dual UNION ALL
select 'Aid On Death' HEADNAME, '50' AMOUNT, '0' BALANCE, '922394' EMPCODE, '1000001' HRM_SALARYHEADTYPE_ID from dual
select t1.Allownces, t1.AMOUNT, t1.BALANCE, t2.Deductions, t2.AMOUNT, t2.BALANCE from
select HEADNAME Allownces, AMOUNT, BALANCE, EMPCODE, 'donnot-match' x from tab where HRM_SALARYHEADTYPE_ID = 1000000
) t1
full outer join
select HEADNAME Deductions, AMOUNT, BALANCE, EMPCODE, 'alright' x from tab where HRM_SALARYHEADTYPE_ID = 1000001
) t2 ON t1.x = t2.x
I need a further step more ...
Desired output ... if HRM_SALARYHEADTYPE_ID = 1000000 then at left side other wise the records come to right side.
HEADNAME......AMOUNT.BALANCE...HEADNAME.......AMOUNT.BALANCE.
Special.Pay......6............0.........Co-Operative.Society...50.....0.
Utility.Bill.........600.........0.........D.E.C.E.Fund..............25.....0.
Tea.Coupen....253.........0.........Aid.On.Death.............50.....0.
or shell i should handle this in reporting tool.
Please reply, now it is very elaborative as well :)
w\
Similar Messages
-
Difference between Innner Join and Cross Join
Dear all,
select * from tbl1 inner join tbl2 on tbl1.id =tbl2.id
select * from tbl1 cross join tbl2
Works same what is the logical difference between this two statements??
Dilip Patil..INNER Join returns the rows from both tables which has satisfied matching condition.
In
CROSS Join, each record from tbl1 is matched with tbl2. Result would be Number Of rows in tbl1 X Number of rows in tbl2.
Note: If you provide where condition in CROSS JOIN, it will give you same result as your first INNER JOIN query
select * from tbl1 cross join tbl2
where tbl1.id =tbl2.id
-Vaibhav Chaudhari -
Cross join a dimension and measure
I am new to MDX, looking at this query, why item(0) in the cross join in the [Top Product Sales] returns just Internet Sales Amount? Isn't the cross join supposed to return a set of (Product, Internet Sales Amount)?
WITH
MEMBER [Measures].[Top Product Sales] AS
EXISTING
TopCount(
[Product].[Product].[Product].Members,
1,
([Measures].[Internet Sales Amount])
{[Measures].[Internet Sales Amount]}
}.Item(0)
,FORMAT_STRING="Currency"
SELECT
([Measures].[Internet Sales Amount]),
([Measures].[Top Product Sales])
} ON COLUMNS,
([Date].[Calendar Year].[CY 2005]),
([Date].[Calendar Year].[CY 2006]),
([Date].[Calendar Year].[CY 2007]),
([Date].[Calendar Year].[CY 2008])
} ON ROWS
FROM [Adventure Works]
If I run the following query, I get a set from both dimensions (product and Internet Sales Amount), which makes sense to me, but why the above cross join return only Internet Sales Amount?
WITH
set x AS
TopCount(
[Product].[Product].[Product].Members,
1,
([Measures].[Internet Sales Amount])
{[Measures].[Internet Sales Amount]}
SELECT
{} ON COLUMNS,
x ON ROWS
FROM [Adventure Works]Hi Thotwielder,
As you said that, the crossjoin return a set of (Product, Internet Sales Amount) which you can see on the screenshot below.
However, you use this set as a calculated measure, product is a dimension other than measure, so it will only use the Internet Sales Amount.
In your scenario, it seems that you want to get the top sales products for each year, right? If in this case, please try the query below.
SELECT
GENERATE
[Date].[Calendar].[Calendar Year].MEMBERS
,TOPCOUNT({[Date].[Calendar].CURRENTMEMBER*[Product].[Product].[Product]},1,[Measures].[Sales Amount]))
ON 1
,[Measures].[Sales Amount] ON 0
FROM [Adventure Works]
Results
If I have anything misunderstanding, please feel free to let me know.
Regards,
Charlie Liao
TechNet Community Support -
Join 3 tables, return records which no match found in table 1 as null
Hi Gurus,
I really need your expert advice. I am stuck in below query.
I have joined 3 tables,
table 2 is an information reference (to get the process code and process name)
table 1 have and table 3 have daily data (which will have the process code and its values/qty)
all values return from table 1 and 3(rtrwip00 and prdyld01) should refer to code in table 1.
There can be a scenario where on a day, a process was stop, so it dont have values/qty in table 1/3,
The problem is my query will return only rows which have records in table 1/3.
While I want all the records in table 2 to be returned no matter have data or not in table 1/3, in case no data in table 1/3, return qty as '0'.
Please advice me..thanks in advance :)
Select lot.rw_oper,
lot.rw_area_grp,
lot.rw_oper_name,
proc_out.proc_out,
lot.rw_qty
from
( SELECT UNIQUE a.rw_oper,a.rw_area_grp,a.rw_oper_name,SUM(CASE WHEN a.rw_qty_unit = 'CM' THEN a.rw_qty*10 ELSE rw_qty END )as rw_qty
From rtrwip00 a, oprinf99 b
WHERE a.rw_facility='MIPOPRD'
AND b.oi_facility = a.rw_facility AND b.oi_oper = a.rw_oper
GROUP BY a.rw_area_grp,a.rw_oper,a.rw_oper_name
ORDER BY a.rw_oper,a.rw_area_grp) lot,
( SELECT py_oper, SUM(CASE WHEN py_out_unit1 = 'CM' THEN py_proc_out1*10 ELSE py_proc_out1 END) proc_out
FROM prdyld01
WHERE py_facility = 'MIPOPRD'
AND py_trs_time between TO_CHAR(SYSDATE-1,'YYYYMMDD')||'070000' AND TO_CHAR(SYSDATE,'YYYYMMDD')||'070000'
group by py_oper
)proc_out
where lot.rw_oper NOT IN ('2900','6700' ,'9100' ,'9920' ,'9921','9940','9941','9300','9500','6700','8910', 'REJT')
and lot.rw_oper = proc_out.py_oper
order by lot.rw_operCREATE TABLE PRDYLD01
PY_FACILITY VARCHAR2(12 BYTE) NOT NULL,
PY_TRS_TIME VARCHAR2(14 BYTE) NOT NULL,
PY_LOT VARCHAR2(11 BYTE) NOT NULL,
PY_OPER VARCHAR2(4 BYTE) NOT NULL,
PY_PO VARCHAR2(12 BYTE) NOT NULL,
PY_PROC_IN1 NUMBER(10,2) DEFAULT 0 NOT NULL,
PY_PROC_IN2 NUMBER(10,2) DEFAULT 0 NOT NULL,
PY_PROC_OUT1 NUMBER(10,2) DEFAULT 0 NOT NULL,
PY_PROC_OUT2 NUMBER(10,2) DEFAULT 0 NOT NULL,
sample data 1
PY_OPER PROC_OUT
3000 481
3100 214
3200 642
3250 291
5250 519
5300 439
5350 476
CREATE TABLE RTRWIP00
RW_FACILITY VARCHAR2(12 BYTE) NOT NULL,
RW_LOT VARCHAR2(11 BYTE) NOT NULL,
RW_OPER VARCHAR2(4 BYTE) NOT NULL,
RW_OPER_NAME VARCHAR2(35 BYTE) NOT NULL,
RW_PO VARCHAR2(12 BYTE) NOT NULL,
RW_AREA_GRP VARCHAR2(12 BYTE) NOT NULL,
RW_QTY NUMBER(10,2) DEFAULT 0 NOT NULL,
RW_QTY_UNIT VARCHAR2(6 BYTE) NOT NULL,
sample data 2
RW_OPER RW_QTY
3000 1248
3100 324
3200 133
3250 357
4400 424
4500 821
4600 909
5050 689
5250 2472
5300 53
5350 166
CREATE TABLE OPRINF99
OI_FACILITY VARCHAR2(12 BYTE) NOT NULL,
OI_OPER VARCHAR2(4 BYTE) NOT NULL,
OI_OPER_SEQ NUMBER(5) NOT NULL,
OI_AREA_GRP VARCHAR2(12 BYTE),
OI_SHORT_DESC VARCHAR2(10 BYTE) NOT NULL,
OI_LONG_DESC VARCHAR2(35 BYTE),
sample data 3
RW_OPER RW_AREA_GRP RW_OPER_NAME
3000 MOD ROD MOUNT
3100 MOD WIRE SAW
3200 MOD AS-CUT CLEANER
3250 MOD BEAM REMOVAL
4400 POL ESE-II
4500 POL EDGE OXIDE STRIP
4600 POL LTO INSPECTION
5050 POL DOUBLE SIDE BUFFER
5250 POL ACCUMULATION
5300 POL FINAL POLISHER
5350 CLN POST POLISH CLEANER
ABove is the DLL for the table and its mock data.
Sample output should be like below; where when no data found in sample data 1, it will return '0'
RW_OPER RW_AREA_GRP RW_OPER_NAME PROC_OUT RW_QTY
3000 MOD ROD MOUNT 481 1248
3100 MOD WIRE SAW 214 324
3200 MOD AS-CUT CLEANER 642 133
3250 MOD BEAM REMOVAL 291 357
4400 POL ESE-II 0 424
4500 POL EDGE OXIDE STRIP 0 821
4600 POL LTO INSPECTION 0 909
5050 POL DOUBLE SIDE BUFFER 0 689
5250 POL ACCUMULATION 519 2472
5300 POL FINAL POLISHER 439 53
5350 CLN POST POLISH CLEANER 476 166
mY current output is below; only return record that have match to all table.
RW_OPER RW_AREA_GRP RW_OPER_NAME PROC_OUT RW_QTY
3000 MOD ROD MOUNT 481 1248
3100 MOD WIRE SAW 214 324
3200 MOD AS-CUT CLEANER 642 133
3250 MOD BEAM REMOVAL 291 357
5250 POL ACCUMULATION 519 2472
5300 POL FINAL POLISHER 439 53
5350 CLN POST POLISH CLEANER 476 166
Really appreciate your response, sorry for taking time to reply.
Thanks in advance :) -
Cross Join Records - only want the "latest valid" records depending on Shop-Level
Hi everyone,
I have a problem with the cross join for my retail application.
Initial Situation:
There are several Shops and in also several products. Usually the products are just created on global level so that all shops can access and sell them.
BUT there is a feature, that single shops can create derivations of articles to change some settings for them (e.g. a the price of a certain handy is global 90€ but in one flagship store the price is 80€).
Sample Tables
create table shops(
id number,
name varchar2(64) not null,
hierarchy varchar2(64) not null,
parent number,
PRIMARY KEY (id));
create table articles(
id number,
name varchar2(64) not null,
price number,
shop_id number not null,
PRIMARY KEY (id));
-- create 4 shops with the hierarchy
- Global
|- Shop A
|- Shop B
|- Shop B.1
insert into shops values (0, 'Global', '.0.', null);
insert into shops values (1, 'Shop A', '.0.1.', 0);
insert into shops values (2, 'Shop B', '.0.2.', 0);
insert into shops values (3, 'Shop B.1', '.0.2.3.', 2);
-- insert some articles + derive the 'Article 2' for shop B.1
insert into articles values (0, 'Article 1', 100, 0);
insert into articles values (1, 'Article 2', 90, 0);
insert into articles values (2, 'Article 2', 80, 3); -- derive article 2 for the shop 2 and set price to 80 instead of 90
Sample Statements
-- restrict to 'Article 1' where no derivations exists
select s.*, a.*
from shops s, articles a
where s.hierarchy like '%.' || a.shop_id || '.%' -- ensures that derivations only appear at the level of the shop and not for each shop
and a.name = 'Article 1';
The result gets the one article for each shop. So I have no problem to restrict to a shop id, and getting the article even if it's not created for that shop level.
Shop ID
Shop Name
Hierarchy
Parent
Article ID
Article Name
Price
Article Shop ID
0
Global
.0.
null
0
Article 1
100
0
1
Shop A
.0.1.
0
0
Article 1
100
0
2
Shop B
.0.2.
0
0
Article 1
100
0
3
Shop B.1
.0.2.3.
2
0
Article 1
100
0
-- restrict to 'Article 2' where one derivation exists
select s.*, a.*
from shops s, articles a
where s.hierarchy like '%.' || a.shop_id || '.%' -- ensures that derivations only appear at the level of the shop and not for each shop
and a.name = 'Article 2';
The result of this statement shows, that the "Article 2" is contained two times for the ShopID 3. This is because the Article exists two times in the articles table.
Shop ID
Shop Name
Hierarchy
Parent
Article ID
Article Name
Price
Article Shop ID
0
Global
.0.
null
1
Article 2
90
0
1
Shop A
.0.1.
0
1
Article 2
90
0
2
Shop B
.0.2.
0
1
Article 2
90
0
3
Shop B.1
.0.2.3.
2
1
Article 2
90
0
3
Shop B.1
.0.2.3.
2
2
Article 2
80
3
Problem1
The last result shows my problem very well. I just want to get the highest level of article if there are any derivations.
Problem2
The solution must be very fast, because I have about
3.000 Shops and about
700.000 different Articles (on global level)
Can somebody help my to find a performant solution for my problem?Hi,
In the output for 'Article 2', do you really want prices of 100 and 65? I assume you meant 90 and 80, like this:
ARTICLE
SHOP SHOP ARTICLE ARTICLE _SHOP
_ID _NAME HIERARCHY PARENT _ID _NAME PRICE _ID
0 Global .0. 1 2 90 0
1 Shop A .0.1. 0 1 2 90 0
2 Shop B .0.2. 0 1 2 90 0
3 Shop B.1 .0.2.3. 2 2 2 80 3
Here's how I got the output above:
WITH joined_data AS
SELECT s.id AS shop_id
, s.name AS shop_name
, s.hierarchy
, s.parent
, a.id AS article_id
, a.name AS article_name
, a.price
, a.shop_id AS article_shop_id
FROM shops s
LEFT OUTER JOIN articles a ON a.shop_id = s.id
AND a.name = 'Article 2' -- or whatever
SELECT shop_id
, shop_name
, hierarchy
, parent
, REGEXP_SUBSTR ( SYS_CONNECT_BY_PATH (article_id, '/')
, '(\d+)/*$'
, 1, 1, NULL, 1
) AS article_id
, REGEXP_SUBSTR ( SYS_CONNECT_BY_PATH (article_name, '/')
, '(\d+)/*$'
, 1, 1, NULL, 1
) AS article_name
, REGEXP_SUBSTR ( SYS_CONNECT_BY_PATH (price, '/')
, '(\d+)/*$'
, 1, 1, NULL, 1
) AS price
, REGEXP_SUBSTR ( SYS_CONNECT_BY_PATH (article_shop_id, '/')
, '(\d+)/*$'
, 1, 1, NULL, 1
) AS article_shop_id
FROM joined_data
START WITH parent IS NULL
CONNECT BY parent = PRIOR shop_id
Like everything else in Oracle, it depends on your version.
I used '/' as a delimiter, assuming that character never occurs in the article_name, article_id, price or shop_id. If '/' can occur in any of those columns, you can use any other character as a delimiter. You don't have to use the same delimiter for all 4 columns, but remember to use the same delimiter in REGEXP_SUBSTR that you use in its nested SYS_CONNECT_BY_PATH.
Instead of doing 4 very similar REGEXP_SUBSTR (SYS_CONNECT_BY_PATH ... ) calls, you could do just 1, for article_id, and then join to the articles table to get the other columns. I suspect that the way I posted above is faster. -
How to avoid duplicates in CROSS JOIN Query
Hi,
I am using CROSS JOIN to get all the subset of a table col values as shown below:
PRODUCT (Col Header)
Bag
Plate
Biscuit
While doing cross join we will get as
Bag Bag
Bag Plate
Bag Biscuit
Plate Bag
Plate Plate
Plate Biscuit ..... like this
By placing where condition prod1 <> prod2 to avoid Bag Bag and Plate Plate values. So the output will be like below
Bag Plate
Bag Biscuit
Plate Bag
Plate Biscuit
Now "Bag Plate" and "Plage Bag" are same combination how to avoid these records. My expected result is
Bag Biscuit
Plate Biscuit
How to derive this ?
SridharHi,
This is the the solution that I found as fit to the OP question, but
Visakh16 already posted the same idea (assuming the names are unique) from the start and I don't think that anyone notice it!
Sridhar.DPM did
you check Visakh16's response
(the second response received)?!?
I will mark his response as an answer. If this is not what you need pls clarify and you can unmark it :-)
[Personal Site] [Blog] [Facebook] -
Fetch multiple rows using cross-join technique
Hello.
Can anyone suggest a method to return 3 rows from a query when only one row would otherwise be returned?
I'm trying to achieve the Logical SQL analog to this -
SELECT x.foo, p.id, p.name FROM people p CROSS JOIN (SELECT 1 AS foo UNION ALL SELECT 2 UNION ALL SELECT 3) x;Reason: I want to force a three (n) row result and use GROUP BY with case statements to create 3-level summary.
Here is a simple Logical SQL expression that works for my OBI setup -
SELECT
"- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number saw_0,
"- Nx_CSDG0_Repair_Orders (Depot Repair Views)".SR_Operating_Unit_Name saw_1
FROM
"[Noetix-NoetixGlobalRepository] NoetixViews for Oracle Service"
WHERE
("- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number = '338246')But I think I cannot do this -
SELECT
"- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number saw_0,
"- Nx_CSDG0_Repair_Orders (Depot Repair Views)".SR_Operating_Unit_Name saw_1
FROM
"[Noetix-NoetixGlobalRepository] NoetixViews for Oracle Service"
CROSS JOIN (SELECT 1 AS foo UNION ALL SELECT 2 UNION ALL SELECT 3)
WHERE
("- Nx_CSDG0_Repair_Orders (Depot Repair Views)".Repair_Number = '338246')But what can I do?
Thank you.
-csHi CSeelig ,
The BI Server uses the ANSI SQL standard. Then all SQL that follows this specification will in OBIEE work.
I have made an example with a densification:
http://gerardnico.com/wiki/dat/obiee/logical_sql/obiee_sql_densification
You will see a cross join to make a densification.
Cheers
Nico -
Formula :using filter with cross join issue
Hi alll,
Ihave one scenario like calclate the ytd values using cross join like
IIF(is ([Flow].CurrentMember,[YTD]),
(case
when
is ([PERIOD].CurrentMember,[2008.01])
Then (Sum (crossjoin({[DI-3]},CrossJoin({[FLOW].[MtD]},{[PERIOD].[2008.01],[PERIOD].[2008.01] })))/2)
when
is ([PERIOD].CurrentMember,[2008.02])
Then (Sum (crossjoin({[DI-3]},crossjoin({[FLOW].[MtD]},{[PERIOD].[2008.01],[PERIOD].[2008.02]}))))
when
is ([PERIOD].CurrentMember,[2008.03])
Then (Sum (crossjoin({[DI-3]},CrossJoin({[FLOW].[MtD]},{[PERIOD].[2008.01],[PERIOD].[2008.02],[PERIOD].[2008.03]))))
etc,othercase)
but I am trying other oneto decrese the size of formula
IIF(is ([Flow].CurrentMember,[YTD]),
(Sum (crossjoin({[DI-3]},CrossJoin({[FLOW].[MtD]},
{filter([PERIOD].Generations(5).members,StrToNum(Right([PERIOD].CurrentMember.MEMBER_NAME,2)) <= StrToNum(Right([PERIOD].CurrentMember.MEMBER_NAME,2)) AND StrToNum(Left([PERIOD].CurrentMember.MEMBER_NAME,4))=StrToNum(left([PERIOD].CurrentMember.MEMBER_NAME,4)) ) }))))
, othercase )
but its result is same value for all the YTDs for every month, something is going wrong some where
plz any help would be appriociated
Thanks in advance
.macearl wrote:
SQL View does not display unless data is returned by the query. Is that normal?
Also, none of these options shows the literal result of the expression we built, i.e.:
expression: CAST(YEAR(TIMESTAMPADD(SQL_TSI_MONTH, -24, CURRENT_DATE)) as CHAR)
result: *2008*
Having the ability to test expressions and see their results would be very helpful in debugging. If anyone knows how to do that please share!
Thanks!
MacOk, Probably shoud have figured this out before, but in response to my own question, the way to view the result of an expression is to add the expression as a column and include it in the Table Presentation.
- Mac (he can be taught) -
Why is a cross join classified as an inner join?
hi guys,
searching the web is just confusing me, so maybe someone here could help.
On wikipedia (for join) it says:
An outer join does not require each record in the two joined tables to have a matching record
Now, a cross join does not require any of the records of the table to have a matching record, therefore I would classify it as an outer join. Why then is it classified as an inner join?
thanksCross join produces the cross-product. You can not specify cross join condition since there is none - it always implies every row in table1 joined with every row in table2:
SQL> select ename,dname from emp cross join dept on(1=1)
2 /
select ename,dname from emp cross join dept on(1=1)
ERROR at line 1:
ORA-00933: SQL command not properly ended
SQL> With outer join you must specify join condition:
SQL> select ename,dname from emp left join dept
2 /
select ename,dname from emp left join dept
ERROR at line 1:
ORA-00905: missing keyword
SQL> And join result rules are completely different - matching rows or NULL row.
SY. -
Illegal cross join within the same dimension
Hi,
When certain fields are selected within the presentation table an "illegal cross join" error is returned by the BI Server. However if a FACT is added from one of the other presentation tables the "illegal cross join" error goes away. we need to query without fact column.
We are getting following error
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 14065] Illegal cross join within the same dimension caused by incorrect subject area setup: [ CALL_CENTER.COUNSELOR_MANAGER T782130] with [ CALL_CENTER.COUNSELOR_HR T781594 On CALL_CENTER.COUNSELOR_HR.MASTER_STAFF_COUNSELOR_ID = CALL_CENTER.MASTER_STAFF_COUNSELOR.MASTER_STAFF_COUNSELOR_ID, CALL_CENTER.MASTER_STAFF_COUNSELOR T781739] (HY000)
Can anybody help me solving this issue.
Thanks,
KS.Please give us an example of what you need.
OBIEE perform a query in the dimension or through the fact table.
You can't join two dimensions in the repository without going through a fact table.
If you need to query without fact column, it's because you have design two dimensions where
normally you can do one.
You have then two solutions :
* change the design of your logical model to make only one dimension.
* use the OBIEE logical SQL in answer.
http://gerardnico.com/wiki/dat/obiee/bi_server/design/obiee_logical_sql
Success
Nico -
I have 2 separate data providers/queries
Let's say in the first one it returns something like this:
OrderId Product Amount
1 Apple 500
1 Orange 400
1 Banana 600
2 Apple 300
2 Orange 200
And in the second one it returns something like this:
OrderId SalesPerson
1 Bob
1 Mary
2 Steve
I'd like to have the webi report output something like this (basically a cross join)
OrderId Product Amount SalesPerson
1 Apple 500 Bob
1 Orange 400 Bob
1 Banana 600 Bob
1 Apple 500 Mary
1 Orange 400 Mary
1 Banana 600 Mary
2 Apple 300 Steve
2 Orange 200 Steve
I think I've tried every combination of merge dimensions/detail objects, etc. but always end up with either #INCOMPATIBLE or #MULTIVALUE in SalesPerson when there are multiple salespersons associated with an order (such as order 1 in the example above). When there is only one SalesPerson associated with the order then it works as expected, such as below:
OrderId Product Amount SalesPerson
1 Apple 500 #MUTLIVALUE
1 Orange 400 #MULTIVALUE
1 Banana 600 #MULTIVALUE
2 Apple 300 Steve
2 Orange 200 Steve
I can't really change the universe, so is this possible to do within webi?Thanks Bala, but I should have mentioned in my original post I tried that as well. It gives me something like this:
OrderId Product Amount SalesPerson
1 Apple 500 Bob
1 Orange 400 Bob
1 Banana 600 Mary
2 Apple 300 Steve
2 Orange 200 Steve
It avoids the #MULTIVALUE, but it doesn't do a proper cross-join. It shows only the number of rows associated with the Product, but doesn't cross-join across SalesPerson. Worse, it seems to "randomly" join against SalesPerson for one of the rows - i.e, I'm not sure why it displayed Mary for one of the rows instead of Bob. -
Return records from Stored Procedure to Callable Statement
Hi All,
I am createing a web application to display a students score card.
I have written a stored procedure in oracle that accepts the student roll number as input and returns a set of records as output containing the students scoring back to the JSP page where it has to be put into a table format.
how do i register the output type of "records" from the stored function in oracle in the "registerOutParameter" method of the "callable" statement in the JSP page.
if not by this way is there any method using which a "stored function/procedure" returning "record(s)" to the jsp page called using "callable" statement be retrieved to be used in the page. let me know any method other that writing a query for the database in the JSP page itself.I have a question for you:
If the stored procedure is doing nothing more than generating a set of results why are you even using one?
You could create a view or write a simple query like you mentioned.
If you're intent on going the stored procedure route, then I have a suggestion. Part of the JDBC 2.0 spec allows you to basically return an object from a CallableStatement. Its a little involved but can be done. An article that I ran across a while back really helped me to figure out how to do this. There URL to it is as follows:
http://www.fawcette.com/archives/premier/mgznarch/javapro/2000/03mar00/bs0003/bs0003.asp
Pay close attention to the last section of the article: Persistence of Structured Types.
Here's some important snippets of code:
String UDT_NAME = "SCHEMA_NAME.PRODUCT_TYPE_OBJ";
cstmt.setLong(1, value1);
cstmt.setLong(2, value2);
cstmt.setLong(3, value3);
// By updating the type map in the connection object
// the Driver will be able to convert the array being returned
// into an array of LikeProductsInfo[] objects.
java.util.Map map = cstmt.getConnection().getTypeMap();
map.put(UDT_NAME, ProductTypeObject.class);
super.cstmt.registerOutParameter(4, java.sql.Types.STRUCT, UDT_NAME);
* This is the class that is being mapped to the oracle object.
* There are two methods in the SQLData interface.
public class ProductTypeObject implements java.sql.SQLData, java.io.Serializable
* Implementation of method declared in the SQLData interface. This method
* is called by the JDBC driver when mapping the UDT, SCHEMA_NAME.Product_Type_Obj,
* to this class.
* The object being returned contains a slew of objects defined as tables,
* these are retrieved as java.sql.Array objects.
public void readSQL(SQLInput stream, String typeName) throws SQLException
String[] value1 = (String[])stream.readArray().getArray();
String[] value2 = (String[])stream.readArray().getArray();
public void writeSQL(SQLOutput stream) throws SQLException
}You'll also need to create Oracles Object. The specification for mine follows:
TYPE Detail_Type IS TABLE OF VARCHAR2(1024);
TYPE Product_Type_Obj AS OBJECT (
value1 Detail_Type,
value2 Detail_Type,
value3 Detail_Type,
value4 Detail_Type,
value5 Detail_Type,
value6 Detail_Type,
value7 Detail_Type,
value8 Detail_Type);Hope this helps,
Zac -
Error in post goods receipt of delivery for a cross company return STO
Hi
I created a cross company return STO in ME21N (with returnd indicator). Vendor V001 (DC) and Site F001.
I created a delivery in VL10B. Delivery Type NCR.
I did a Goods Receipt for STO. Movement Type 161. Internally stock in issued from site F001.
I am trying to do a Post Goods Receipt of the Delivery in VL02N and I am getting this error.
Delivery quantity is greater than supplying site stock quantity
Message no. VL900
Supplying site is F001 which has enough stock.
DC has no stock and I amtrying to return stock to DC from store.
How to eradicate this issue?
Thanks and RegardsHi
http://wiki.sdn.sap.com/wiki/display/B1/SAPBusinessOne...ToGo-3.TheBasicsofFinancial+Accounting
http://help.sap.com/saphelp_sbo88/helpdata/en/45/06b9997d720487e10000000a155369/content.htm
kiran -
Creation of Data Control for custom java method which will return records
Hi Guys,
I have a requirement of creating a a custom java method in App module which will return a record set taking an id as input.In case of single return type it works fine but in case of returning record set it is not working.In my case i have to combine two tables and return it as a single entity as a view in Data Control.
Warm Regards,
Srinivas.Why don't you just create a custom view object? There's even an example or 2 in the docs:
http://docs.oracle.com/cd/E16162_01/web.1112/e16182/intro_tour.htm#CHDGDIEC (check out "View object on refcursor" example)
Edit: you are aware that you can create a View Object based on more than one table?
John -
I can't figure out how to combine a full outer join with another type of join ... is this possible?
Here's some create table and insert statements for some basic sample data:
CREATE TABLE my_tab1
( record_id NUMBER NOT NULL
, workstation VARCHAR2(4)
, my_value NUMBER
CONSTRAINT my_tab1_pk PRIMARY KEY (record_id)
INSERT INTO my_tab1
VALUES(1,'ABCD',10);
INSERT INTO my_tab1
VALUES(2,'ABCD',15);
INSERT INTO my_tab1
VALUES(3,'ABCD',5);
INSERT INTO my_tab1
VALUES(4,'A123',5);
INSERT INTO my_tab1
VALUES(5,'A123',10);
INSERT INTO my_tab1
VALUES(6,'A123',20);
INSERT INTO my_tab1
VALUES(7,'????',5);
CREATE TABLE my_tab2
( workstation VARCHAR2(4)
, wkstn_name VARCHAR2(20)
CONSTRAINT my_tab2_pk PRIMARY KEY (workstation)
INSERT INTO my_tab2
VALUES('ABCD','WKSTN 1');
INSERT INTO my_tab2
VALUES('A123','WKSTN 2');
INSERT INTO my_tab2
VALUES('B456','WKSTN 3');
CREATE TABLE my_tab3
( my_nbr1 NUMBER
, my_nbr2 NUMBER
INSERT INTO my_tab3
VALUES(1,2);
INSERT INTO my_tab3
VALUES(2,3);
INSERT INTO my_tab3
VALUES(3,4);And, the results I want to get:
workstation sum(my_value) wkstn_name my_nbr1 my_nbr2
ABCD 30 WKSTN 1 1 2
ABCD 30 WKSTN 1 2 3
ABCD 30 WKSTN 1 3 4
A123 35 WKSTN 2 1 2
A123 35 WKSTN 2 2 3
A123 35 WKSTN 2 3 4
B456 0 WKSTN 3 1 2
B456 0 WKSTN 3 2 3
B456 0 WKSTN 3 3 4
???? 5 NULL 1 2
???? 5 NULL 2 3
???? 5 NULL 3 4I've tried a number of different things, googled my problem, and no luck yet...
SELECT t1.workstation
, SUM(t1.my_value)
, t2.wkstn_name
, t3.my_nbr1
, t3.my_nbr2
FROM my_tab1 t1
, my_tab2 t2
, my_tab3 t3
...So, what I want is a full outer join of t1 and t2 on workstation, and a cross-join of that with t3. I'm wondering if I can't find any examples of this online because it's not possible....
Note: I'm stuck dealing with Oracle 8i
Thanks!!Hi,
The query I posted yesterday is a little more complicated than it needs to be.
Since my_tab2.workstation is unique, there's no reason to do a separate sub-query like mt1; we can join my_tab1 to my_tab2 and get the SUM all in one sub-query.
SELECT foj.workstation
, foj.sum_my_value
, foj.wkstn_name
, mt3.my_nbr1
, mt3.my_nbr2
FROM ( -- Begin in-line view foj for full outer join
SELECT mt1.workstation
, SUM (mt1.my_value) AS sum_my_value
, mt2.wkstn_name
FROM my_tab1 mt1
, my_tab2 mt2
WHERE mt1.workstation = mt2.workstation (+)
GROUP BY mt1.workstation
, mt2.wkstn_name
UNION ALL
SELECT workstation
, 0 AS sum_my_value
, wkstn_name
FROM my_tab2
WHERE workstation NOT IN ( -- Begin NOT IN sub-query
SELECT workstation
FROM my_tab1
WHERE workstation IS NOT NULL
) -- End NOT IN sub-query
) foj -- End in-line view foj for full outer join
, my_tab3 mt3
ORDER BY foj.wkstn_name
, foj.workstation
, mt3.my_nbr1
, mt3.my_nbr2
;Thanks for posting the CREATE TABLE and INSERT statements, as well as the very clear desired results!
user11033437 wrote:
... So, what I want is a full outer join of t1 and t2 on workstation, and a cross-join of that with t3. That it, exactly!
The tricky part is how and when to get SUM (my_value). You might approach this by figuring out exactly what my_tab3 has to be cross-joined to; that is, exactly what should the result set of the full outer join between my_tab1 and my_tab2 look like. To do that, take your desired results, remove the columns that do not come from the full outer join, and remove the duplicate rows. You'll get:
workstation sum(my_value) wkstn_name
ABCD 30 WKSTN 1
A123 35 WKSTN 2
B456 0 WKSTN 3
???? 5 NULL So the core of the problem is how to get these results from my_tab1 and my_tab2, which is done in sub-query foj above.
I tried to use self-documenting names in my code. I hope you can understand it.
I could spend hours explaining different parts of this query in more detail, but I'm sure I'd waste some of that time explaining things you already understand. If you want an explanation of somthing(s) specific, let me know.
Maybe you are looking for
-
Open multiple files at the same time
Dear everyone, Suppose we have an array of millions of integers, we wanna create 10 files: 0.txt (stores the integers in that array whose last bit is 0.) 1.txt (stores the integers in that array whose last bit is 1.) 2.txt (stores the integers in tha
-
HT2508 how do i connect a projector to show youtube videos?
my projector will show powerpoint presentations, but not dvds or internet material. how do I get these?
-
Paid for the iOS program renewal, but it still shows it as expired
Hi, I paid for a renewal almost a month ago, and I see the bill from Apple in my bank account, but my account is still expired and it asks me to renew it. I tried to contact support via e-mail three times already with no success, what can I do? Danny
-
How can I format a F type?
Hi experts! I need help, TYPES: dato TYPE F. DATA: CANTIDAD TYPE dato. CANTIDAD = 1200/ 5 And this return me 2.4000000000000000E+02 I need to format this number into 240 can anybody tell me how? Thanks a lot Regards, Rebeca
-
Adjusting color saturation hp 5520e all-in-one
Some time ago, I had a HP c4580 photosmart all-in-one printer, which had the option available to adjust color saturation, warmth, brightness, etc. I later purchased a HP 5520e photosmart all-in-one printer, which doesn't seem to have that option. I