Query writing
please help with a query that joins at least four tables together
Thanks
Tokunbo
Please provide more information, such as the table layouts and what ties them together.
for example:
DESC EMP
Name Null? Type
ENAME VARCHAR2(20)
EMPNO NUMBER
MGR NUMBER
JOB VARCHAR2(20)
DEPT_NO NUMBER
DESC DEPT
Name Null? Type
DEPT_NO NUMBER
DEPT_NAME VARCHAR2(20)
Here obviously is tie together by dept_no. So a query would be
select d.dept_name, e.ename, e.job
from dept d, emp e
where d.dept_no = e.dept_no
please help with a query that joins at least four tables together
Thanks
Tokunbo
Similar Messages
-
Front end query writing.
Hi gurus,
I know about query designer, Bex analyzer, Bex browser and other related topics such as variables, Conditions and exceptions? But i cant understand what's this Front end query writing or Back end data modelling. Will you plz give me detailed description on this topic, how it should be used in real time scenario.
Thanks,
Sameer.Hi Sameer
If I understand ur question correctly
<b>query designer, Bex analyzer, Bex browser and other related topics such as variables, Conditions and exceptions?</b> all these are for creating queries and used for generating reports. So these come front end side.
And abt <b>Back end data modelling</b>, it is modelling thing we do in Adminstrator work bench(RSA1) i.e creating infoobjects, datatargets etc.,
In real time we will get the data from source system and store it in the data targets and infoobjects we modelled in AWB and then we report on this datatargets.
So this ETL and modelling part becomes back end and Reporting becomes front end.
I think it's clear for u now
Any doubts let me know
Regards
Kiran -
(view hint or Query writing method) using views in Select Query
Need Assistance,
Hi all,
My database having many views. while i am joining the views in a select query increase the cost of the querys due to the complex joins in the conditions.
While checking the select query with views individualy taking less cost.
Does any hint or query writing method is availabe to avoid the merging of the execution plan of the views?
I have browsed many related to the mentioned issues,couldn't found any thing that helps me.
Please help me on this issue,it will be very much helpfull for me.
Thanks,
SenthurPlease read the two threads linked to in the FAQ: {message:id=9360003} and post the relevant details they request, so that people can help you better with your issue.
We cannot help if you just say "my query is slow what do I do to fix it" as we cannot see your queries, your data, or any other information we would need to help. If the answer was that simple, it would be built into oracle so that the optimiser would fix it for you. -
Sql query writing best practises
HI forum,
Any body is having a tutorial on sql query writing best practises...pls share with me
ThanksFor example:
[url http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/toc.htm]Oracle Database Performance Tuning Guide 10g Release 2 (10.2)
[url http://people.aapt.net.au/roxsco/tuning/]Oracle SQL Tuning Guide
Gints Plivna
http://www.gplivna.eu -
Hi,
I've select query to retrive the data in the following order
Sequnce ID Model Barcode
1 Dell 123
2 Dell 124
3 Dell 125
4 HP 126
5 hp 127
6 hp 128
7 apple 129
8 apple 130
I want the following to be selected round robin for Dell and Hp laptop alone as mentioned below.
Sequnce ID Model Barcode
1 Dell 123
4 HP 126
2 Dell 124
5 hp 127
3 Dell 125
6 hp 128
7 apple 129
8 apple 130
Can you help me to acheive this?
Thanks!Hi,
user601042 wrote:
Hi,
I've select query to retrive the data in the following order
Sequnce ID Model Barcode
1 Dell 123
2 Dell 124
3 Dell 125
4 HP 126
5 hp 127
6 hp 128
7 apple 129
8 apple 130If that's what you want, then it looks like
ORDER BY barcodeis all you need.
If you want the results sorted as below, Then you can use the analytic ROW_NUMBER function:
ORDER BY CASE
WHEN UPPER (model) IN ('DELL', 'HP')
THEN ROW_NUMBER () OVER ( PARTITION BY UPPER (model)
ORDER BY barcode
END
, barcode
I want the following to be selected round robin for Dell and Hp laptop alone as mentioned below.
Sequnce ID Model Barcode
1 Dell 123
4 HP 126
2 Dell 124
5 hp 127
3 Dell 125
6 hp 128
7 apple 129
8 apple 130Either way, I assume that sequnce id is not actually in your table.
Edited by: Frank Kulash on Mar 14, 2013 12:38 PM
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ {message:id=9360002} -
SQL query writing limit exceeded.
Hi,
My query contains 1700 lines and the report builder query writen provide line maximum line limit is 1615. When i paste the query in SQL area of report builder, Its paste the 1615 lines and remaining lines cutoff.Its provide the facility to type the query but not to paste the query further. According to the Scenario i cant able to create the view.So please tell me how can i handle it.
Thanks.Does the query really have to be that big?
I suspect a query of that size would be almost impossible to maintain or debug, assuming the performance is ok.
I would suggest that you review the query to see if there are some parts which could be separated out into formula columns, or possibly split the query up - maybe if the report has a number of groups you could break it up that way.
Generally when you hit an issue of this sort it is best to make your code fit the tools rather that the other way round. -
I have one table for Loan_mst
Below is the data for column name, salary and loan
Here one person can have multiple loan, multiple loan are separted by ,.
Example CAR1, CAR2, HOME1 . There are three loan separated by comma.
name
salary
Loan
robert
1000000
CAR1, CAR2, HOME1
albert
2520000
CAR1, CAR2, HOME2, HOME3
Using query i want to write data like below.
name
salary
New column
robert
1000000
CAR1
robert
1000000
CAR2
robert
1000000
HOME1
albert
2520000
CAR1
albert
2520000
CAR2
albert
2520000
HOME2
albert
2520000
HOME3
Please help me with the sql query.Why are you storing multiple value in the column LOAN. That not the correct way to design you table. Your table is in violation of 1NF. 1NF states the column value must be atomic.
Said that your requirement can be achieved like this.
SQL> with t
2 as
3 (
4 select 'robert' name, 1000000 salary, 'CAR1, CAR2, HOME1' loan
5 from dual
6 union all
7 select 'albert' name, 2520000 salary, 'CAR1, CAR2, HOME2, HOME3' loan
8 from dual
9 )
10 -- End of test data
11 select name
12 , salary
13 , trim(regexp_substr(loan, '[^,]+', 1, level)) loan
14 from t
15 connect by level <= length(loan) - length(replace(loan, ',')) + 1
16 and prior name = name
17 and prior sys_guid() is not null
18 /
NAME SALARY LOAN
albert 2520000 CAR1
albert 2520000 CAR2
albert 2520000 HOME2
albert 2520000 HOME3
robert 1000000 CAR1
robert 1000000 CAR2
robert 1000000 HOME1
7 rows selected. -
Hello
i want to write a query like that
here is my table test1
FNAME PTYPE
adeel a
adeel a
qasim a
qasim b
asim b
asim b
6 rows selectedrequire output like
Fname count(a) count(b)
adeel 2 -
qasim 1 1any samr way to do in sql ?Why isn't 'asim' in your output?
Anyway, this might give an idea:
SQL> -- generating sample data:
SQL> with test1 as (
2 select 'adeel' fname, 'a' ptype from dual union all
3 select 'adeel', 'a' from dual union all
4 select 'qasim', 'a' from dual union all
5 select 'qasim', 'b' from dual union all
6 select 'asim', 'b' from dual union all
7 select 'asim', 'b' from dual
8 )
9 --
10 -- actual query:
11 --
12 select fname
13 , sum(case when ptype = 'a' then 1 else 0 end) "count(a)"
14 , sum(case when ptype = 'b' then 1 else 0 end) "count(b)"
15 from test1
16 group by fname;
FNAME count(a) count(b)
adeel 2 0
qasim 1 1
asim 0 2 -
oracle 10g.
os : linux
table data appears like this
SQL> select * from test_grp;
COL1 COL2
aaa 111
aaa 444
aaa 222
bbb 333
bbb 555
SQL> select * from test_grp order by 2;
COL1 COL2
aaa 111
aaa 222
bbb 333
aaa 444
bbb 555
As per my application requirement I need to seggerage the data as
follows
aaa (2) ie --- 111,222
bbb(1) is --- 333
aaa(1) is --- 444
bbb(1) is -- 555
I am not able to frame this. Any help ?SQL> create table test_grp
2 as
3 select 'aaa' col1, 111 col2 from dual union all
4 select 'aaa', 444 from dual union all
5 select 'aaa', 222 from dual union all
6 select 'bbb', 333 from dual union all
7 select 'bbb', 555 from dual
8 /
Tabel is aangemaakt.
SQL> select col1
2 , col2s
3 from ( select col1
4 , rtrim(col2s,',') col2s
5 , rn
6 , sumn
7 from ( select col1
8 , col2
9 , sum(n) over (order by col2) sumn
10 from ( select col1
11 , col2
12 , case when col1 = lag(col1) over (order by col2) then 0 else 1 end n
13 from test_grp
14 ) t
15 )
16 model
17 partition by (sumn)
18 dimension by (row_number() over (partition by sumn order by col2) rn)
19 measures (col1, cast(col2 as varchar2(100)) col2s)
20 rules
21 ( col2s[any] order by rn desc = col2s[cv()] || ',' || col2s[cv()+1]
22 )
23 )
24 where rn = 1
25 order by sumn
26 /
COL COL2S
aaa 111,222
bbb 333
aaa 444
bbb 555
4 rijen zijn geselecteerd.Regards,
Rob. -
Credit Memo and AR Invoice Query
Hi Everyone,
I'm fairly new to query writing and need to write a query that would list all of the credit memos and invoices. I was able to write the following query that pulls just the AR Invoice info. How do I also pull the AR Credit Memo info?
SELECT T0.[CardCode], T0.[DocNum], T0.[DocDate], T1.[Quantity], T1.[ItemCode], T1.[PriceBefDi], T1.[StockPrice] FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry ORDER BY T0.[CardCode], T0.[DocNum]
When using the generator it does not link the tables together in any fashion. I tried to just add the ORIN and RIN1 tables to it (as I can just have them listed below the invoices), but SAP appears to just lock up and I end up closing the application.
I searched the forum as well and found that there is a link between the two and it is:
RIN1.BaseEntry = OINV.DocEntry
and
INV1.TrgetEntry = ORIN.DocEntry
However, when I try to add these joins to the query, it ends up showing a credit memo for every single line, and I know that is not correct. I know there are different types of joins, so perhaps I'm using the wrong join or something?
I appreciate anybody's help.
Thank you,
AmandaHi Amanda,
Try this one:
SELECT T0.CardCode, T0.DocNum, T0.DocDate, T1.Quantity, T1.ItemCode, T1.PriceBefDi,
T1.StockPrice FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
UNION ALL
SELECT T0.CardCode, T0.DocNum, T0.DocDate, T1.Quantity, T1.ItemCode, T1.PriceBefDi,
T1.StockPrice FROM ORIN T0 INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry
ORDER BY T0.CardCode, T0.DocNum
Thanks,
Gordon -
Nested query in BPEL JDeveloper
Hi,
Can anyone help me with nested query writing in BPEL (JDeveloper)
the query is :
SELECT LENGTH, WIDTH, HEIGHT, WEIGHT,
LENGTH*WIDTH* HEIGHT AS ITEM_CUBE
FROM ITEM_SUPP_COUNTRY_DIM
WHERE ITEM= <Level1 item>
AND DIM_OBJECT= (SELECT CASE_NAME FROM ITEM_SUPPLIER WHERE ITEM=<Item> AND PRIMARY_SUPP_IND = ‘Y')
Please help me with the steps.
Many thanksHi,
For the following query:
SELECT S.STORE, S.STORE_NAME, A.ADD_1, A.ADD_2, A.ADD_3, A.CITY,A.STATE, A.POST, A.COUNTRY_ID, A.CONTACT_PHONE, A.CONTACT_NAME,S.STORE_OPEN_DATE, S.STORE_CLOSE_DATE, S.REMODEL_DATE, S.TRANSFER_ZONE,S.DISTRICT,S.STORE_TYPE
FROM STORE S, ADDR A
WHERE S.STORE= #store
AND to_char(S.STORE) = #keyValue1
AND A.MODULE = #module
AND A.ADDR_TYPE = #type
AND A.PRIMARY_ADDR_IND=#addrType
the DB adapter shows this xml:
<?xml version = '1.0' encoding = 'UTF-8'?>
<xs:schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/WMSStoreDataLookUp" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/WMSStoreDataLookUp" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="WMSStoreDataLookUpInput" type="WMSStoreDataLookUpInput"/>
<xs:complexType name="WMSStoreDataLookUpInput">
<xs:sequence>
<xs:element name="store" type="/><br /><br /> <xs:element name="keyValue1" type="/>
<xs:element name="module" type="/><br /><br /> <xs:element name="type" type="/>
<xs:element name="addrType" type="/><br /><br /> </xs:sequence><br /><br /></xs:complexType><br /><br /><xs:element name="WMSStoreDataLookUpOutputCollection" type="WMSStoreDataLookUpOutputCollection" nillable="true"/><br /><br /><xs:complexType name="WMSStoreDataLookUpOutputCollection"><br /><br /><xs:sequence><br /><br /><xs:element name="WMSStoreDataLookUpOutput" type="WMSStoreDataLookUpOutput" minOccurs="0" maxOccurs="unbounded"/><br /><br /></xs:sequence><br /><br /></xs:complexType><br /><br /><xs:complexType name="WMSStoreDataLookUpOutput"><br /><br /><xs:sequence><br /><br /><xs:element name="S_STORE" type="xs:decimal" nillable="true"/><br /><br /><xs:element name="S_STORE_NAME" type="xs:string" nillable="true"/><br /><br /><xs:element name="A_ADD_1" type="xs:string" nillable="true"/><br /><br /><xs:element name="A_ADD_2" type="xs:string" nillable="true"/><br /><br /><xs:element name="A_ADD_3" type="xs:string" nillable="true"/><br /><br /><xs:element name="A_CITY" type="xs:string" nillable="true"/><br /><br /><xs:element name="A_STATE" type="xs:string" nillable="true"/><br /><br /><xs:element name="A_POST" type="xs:string" nillable="true"/><br /><br /><xs:element name="A_COUNTRY_ID" type="xs:string" nillable="true"/><br /><br /><xs:element name="A_CONTACT_PHONE" type="xs:string" nillable="true"/><br /><br /><xs:element name="A_CONTACT_NAME" type="xs:string" nillable="true"/><br /><br /><xs:element name="S_STORE_OPEN_DATE" type="xs:dateTime" nillable="true"/><br /><br /><xs:element name="S_STORE_CLOSE_DATE" type="xs:dateTime" nillable="true"/><br /><br /><xs:element name="S_REMODEL_DATE" type="xs:dateTime" nillable="true"/><br /><br /><xs:element name="S_TRANSFER_ZONE" type="xs:decimal" nillable="true"/><br /><br /><xs:element name="S_DISTRICT" type="xs:decimal" nillable="true"/><br /><br /><xs:element name="S" type="xs:string" nillable="true"/><br /><br /><xs:element name="A_PRIMARY_ADDR_IND__addrType" type="xs:string" nillable="true"/><br /><br /></xs:sequence><br /><br /></xs:complexType><br /><br /></xs:schema><br /><br /><br /><br />Please, look at the last few lines of XML and let me know if this is correct.. -
How can i use a structure into a query (writing code)? In some documents (SO, PO, etc.), some fields are into a structure. How can i use that field into a query?
Thank you.
Edited by: Was Wasssu on Feb 3, 2009 3:29 PMHi Was
You may use it like
SELECT <field1> <field2> FROM <databasetable> INTO <internaltable>
WHERE <field1> EQ <structure>-<field1>
AND <field2> EQ <structure>-<field2>.
Pushpraj -
Bex3.5 query to Business Objects
Hello experts.
Can anyone tell me on the possibilities of porting the Bex 3.5 queries directly to Business Objects.
This is without upgrading to BI 7.0 queries.
Thanks
MrinaliniHi Mrinalini,
I am agree with Shiva for data up gradation in BOE You can use webi. XI 3.1 and SAP BEX .
Best performance optimizations are done on both SAP BW backend on SP5 and on BOXI 3.1 on Service pack 2 Fixpack 2.1.
For Web Intelligence, Crystal Reports) even if you have built them with the Query Designer 3.5. in BEX Query analyzer who support BOE 3.1 , You can use your stuff for best Query writing , design for the same !!
Regards,
Asish -
Query generation basic documentation
Dear Friends,
Is there any documentation for query writing.
Ex.
How to use inner join , why?
what is T0 (normally we observed in query)
Syntax and its use.
Overall, i want fundamentals of making query.
Regards,
MAhesh.Hi,
The document u r looking for might not be available in sap documents but u can better search for sql tutorials.
As far as u asked about T0 , its nothing else but just a alias name used for the first table used in a query.
I.E.
if we want a report using two tables then either we can write
select ordr.docnum,ordr.docdate,rdr1.itemcode from ordr innerjoin Rdr1 on ordr.docentry= rdr1.docentry
or else u can replace ordr with T0 Nd rdr1 with T1
and the query wud look like
Select T0.docnum,T0.docdate,T1.itemcode from ordr T0 innerjoin Rdr1 T1 on T0.DocEntry = T1.DocEntry .
and as u asked about the basic syntax
then a simple query format is
Select columnname from tablename where 'specify ur conditions'
Hope this might be helpful to u .
Thanks
Abhishek -
Install Oracle 10g with Toad 9.1
Hi All,
I am a novice in database(SQL,PLSQL) programming and hence want to learn and practise very deeply in detail for which i want to install Oracle 10g client with Toad 9.1.So need your advise on the process.
(a)Do i need to download entire Oracle Enterprise Edition Installation for Vista? I have read in one of the forums that downloading only the Oracle Client is enough?
Can you please advise me?
(b)I already have the TOAD 9.1 setup with me which i can install.But,i do not know that how will i use TOAD interface and connect to the oracle database.
(c)Also,any sample script/database with some tables that i can use for learning complex SQL query writing would be very helpful.In brief-any project that i can work on in building all the requirements by writing SQL which simulates real time scenarios of SQL development.
Please help me ,i am struggling.
Thanks
DevHi all,
Thanks a lot for all your inputs.Its very useful and presently I am following the steps suggested.
I had another doubt with respect to this.While attending a oracle course,the instructor had told about an installation option of installing oracle 10g on Linux using VMware/virtual -i am sorry i am not sure about it.
So,can you please give your inputs about this process as I dont know about how to setup?
(a)What are the tools that i will need to build a virtual machine in my present computer with Linux as the OS?
And,what are the steps we need to do ?
(b)How do i use a vitual machine if i install it? I mean how will it work?
(c)Then,at last how do i install Oracle with Linux on that?
Please help me with some more inputs
--Dev
Maybe you are looking for
-
Error Message when trying to run Applications Module in OA Framework
Below is the message that I received when trying to run my Applicaitons Module in test mode. When I click the error message I navigate to "public class TpcApBanksEOImpl extends OAEntityImpl". I was told to put "abstract" before "class" and to run it.
-
Hi Guys, I have posted a customer invoice today with a foreign currency. So its an open item as it is still not paid. Then i am running the Forex Valuation for the customer open items. However the exchange rate has not changed between the two currenc
-
Date format conversion in Business Server pages
Hi Floks i am working Business server pages i got some problem in the date format. Igetting date as dd.mm.yyyy and i want to change this to MM/DD/YYYY format . i tried to change this in like in ABAP coding . it s not working can give how can fixthis
-
Hi, For RG1 update, In Tcode j1i5 after filling all respective parameters when we execute, a list of material doc for finished goods displayed but after simulate green light appers, then again we do simulate then by selecting material doc when we cli
-
Original dates in comparison of actual dates
Hi Experts I have a project with certain activities and partily executed (few activities are confirmed and partially confirmed). For the finally confirmed activities, the planned earliest and latest dates if activity are matched with actual dates. To