Select Query and Join Between int and Numeric(22)
I have two tables
tablea
Field1 int
tableb
Field1 Numeric(22)
I know this design is wrong but this is what I have ?
tablea contains about 12M records
Field1 in tablea is one to one related to Field1 in tableb
Now I have Select Query
Select tablea.* from tablea,tableb where tablea.field1=tableb.field1 and tableb.field2 > somrthing
Query here is
Does Join Between
int type
Yes, avinash said rightly.
there is another way bit diffict.
use the indexes properly as available in the mseg table and mkpf table even then it is diffcult
else try using BAPI.
some bapi will give the entire details of the MATERAIL DOCUMENT
go to BAPI explorer tcode BAPI.
where you can find the BAPI name like the 'GET_LIST'.
Try this.
hope this will serve your purpose.
Thanks and regards
Ramchander Rao.K
Similar Messages
-
In oracle rac, If user query a select query and in processing data is fetched but in the duration of fetching the particular node is evicted then how failover to another node internally?
The query is re-issued as a flashback query and the client process can continue to fetch from the cursor. This is described in the Net Services Administrators Guide, the section on Transparent Application Failover.
-
Hi,
Please give me the Select query
I have to fetch EBELN,BUKRS,LIFNR,BSART,EKORG,EKGRP,WAERS,WKURS from EKKO and
EBELP,LGORT,MATKL ,WERKS,BEDNR,IDNLF,BPRME,NETPR from EKPO and
MENGE, SAKTO,AUFNR,ANLN1,GSBER,PS_PSP_PNR from EKKN and
LPEIN,EINDT,SLFDT, from EKET.
I have to fetch all the data into an single internal table(Mandatory) by a select query using Joins.
EKKO is having EBELN as primary key
EKPO is having EBELN,EBELP as primary key
EKKN is having EBELN,EBELP as primary key
EKET is having EBELN,EBELP as primary key
Can anybody Please give me the Select query.
With Regards
AjayHi ,
I am sending this sample coed for the Inner joins .Hope this will help you:
Inner joins using 3 tables
Try this :-
SELECT stpostlnr stpoidnrk mastmatnr maramtart stpo~menge
INTO CORRESPONDING FIELDS OF TABLE zmat1 FROM mast
JOIN stpo ON stpostlnr = maststlnr
JOIN mara ON maramatnr = mastmatnr
WHERE stpostlty = 'M' "AND stpoidnrk IN s_matnr
AND mast~werks = 1000.
Here s_matnr is a select-options on the selection-screen.
Or this.
Code:
Select single VbrkBukrs VbrkKunrg Vbrk~Vbeln
VbrkFkdat VbrkBstnk_Vf Vbrk~Zterm
Tvzbt~Vtext
VbakVbeln VbakBstdk
LikpVbeln Likplfdat Likp~Lfuhr
into w_vbrk
from vbrk
inner join Tvzbt on TvzbtZterm = VbrkZterm and
Tvzbt~Spras = sy-langu
Inner join Vbfa as SalesLnk
on SalesLnk~vbeln = pu_vbeln and
SalesLnk~vbtyp_v = c_order
inner join Vbak on VbakVbeln = SalesLnkVbelv
Inner join Vbfa as DeliveryLnk
on DeliveryLnk~vbeln = pu_vbeln and
DeliveryLnk~vbtyp_v = c_Delivery
inner join Likp on LikpVbeln = DeliveryLnkVbelv
where vbrk~vbeln = pu_Vbeln.
This code locates sales, delivery and payment terms info from a billing document number.
or
Here, this one also works fine :
select zfpcdcadivi zfpcdproforma zfpcdfactura zfpcdaniofactura
zfpcdmontousd zfpcdmontoap zfpcdebeln zfpcdinco1
zfpcdlifnr lfa1name1 zcdvsstatus zfpcdconint
into it_lista
from zfpcd inner join zcdvs
on zfpcdebeln = zcdvsebeln
and zfpcdproforma = zcdvsproforma
and zfpcdlifnr = zcdvslifnr
inner join lfa1
on zfpcdlifnr = lfa1lifnr
where zcdvs~status = '04'.
Also Here is another solution that just uses inner joins:
SELECT vbakvbeln vbfaerdat INTO (itab-vbeln, itab-wadat)
FROM ( vbak INNER JOIN vbap
ON vbapvbeln = vbakvbeln )
INNER JOIN vbfa ON vbakvbeln = vbfavbelv
WHERE vbak~kunnr = m_wm AND
vbak~vbtyp = 'C' AND
vbfa~erdat IN s_date AND
vbap~matnr = 'MZ1807F' AND
vbfaposnv = vbapposnr AND
vbfa~vbtyp_n = 'J'.
<REMOVED BY MODERATOR>
Cheers,
Chandra Sekhar.
Edited by: Alvaro Tejada Galindo on Apr 10, 2008 5:20 PM -
Dynamic From statement in select query and/or outer join not working
Dear Experts, I have a select query where the select columns are dynamic, the where condition is also dynamic. It is of the below format:
Select (dynamic columns) INTO <wa>
FROM a inner join b on af1 = bf1
inner join c on af2 = cf2......
WHERE (dynamic conditios)
ORDER BY ( dynamic sort condition).
Now I have to include some tables (dynamically depending on the user input) in the inner join statement which will give description for the selected fields. And these database tables may or may no be empty. So in this case, my select query will not return any data if these tables are empty. And I dont want that.
I tried using outer join for the extra tables but it gave me a runtime error. I also tried forming the inner join statement dynamically but it was not supporting.
Kindly give me pointers.
ThanksHey thanks for the reply, but the problem is not solved.
I am already using ( fileds, value) like table in my where condition and the select statement was working properly.
the problem is that now I have to include some tables in the join statement which can be empty and so i want to use Outer join.
But I am getting a runtime error as below:
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SYNTAX', was not
caught in
procedure "ZATSCSNG_RFC_READ_TABLE" "(FUNCTION)", nor was it propagated by a
RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
The running ABAP program wanted to execute a SELECT statement whose
WHERE condition was (partly) specified dynamically. The part that is
specified in an internal table at runtime is compared to a field of the
right table of an LEFT OUTER JOIN. Such comparisons are not supported by
all database systems and are therefore not allowed. -
Hi All,
I had to modify the current select query coz its taking a lot of database time, please suggest the best solution for the below.
SELECT msegbukrs mkpfbudat mkpf~bldat
msegebeln mkpfxblnr mseg~mblnr
msegmjahr msegzeile mseg~xauto
msegparent_id msegwerks mseg~umwrk
msegumlgo msegparent_id ekko~reswk
msegwerks mseglgort mseg~matnr
msegerfmg msegerfme mseg~shkzg
msegsjahr msegsmbln mseg~smblp
msegcharg ekkobedat
INTO TABLE g_tbl_main
FROM mkpf JOIN mseg
ON mkpfmandt = msegmandt AND
mkpfmblnr = msegmblnr AND
mkpfmjahr = msegmjahr
JOIN ekko ON msegmandt = ekkomandt AND
msegebeln = ekkoebeln
JOIN likp ON mkpfxblnr = likpvbeln
CLIENT specified
WHERE mkpf~mandt = sy-mandt AND
mkpf~budat IN s_budat AND
ekko~bedat IN s_bedat AND
mseg~ebeln IN s_ebeln AND
mkpf~xblnr IN s_vbeln AND
likp~vstel IN s_vstel AND
ekko~reswk IN s_reswk AND
mseg~werks IN r_werks AND
mseg~lgort IN s_lgort AND
mseg~matnr IN s_matnr AND
mseg~smbln = space AND
mseg~bwart IN s_bwart AND
mseg~kzzug = c_true.Yes, avinash said rightly.
there is another way bit diffict.
use the indexes properly as available in the mseg table and mkpf table even then it is diffcult
else try using BAPI.
some bapi will give the entire details of the MATERAIL DOCUMENT
go to BAPI explorer tcode BAPI.
where you can find the BAPI name like the 'GET_LIST'.
Try this.
hope this will serve your purpose.
Thanks and regards
Ramchander Rao.K -
Performance issue with select query and for all entries.
hi,
i have a report to be performance tuned.
the database table has around 20 million entries and 25 fields.
so, the report fetches the distinct values of two fields using one select query.
so, the first select query fetches around 150 entries from the table for 2 fields.
then it applies some logic and eliminates some entries and makes entries around 80-90...
and then it again applies the select query on the same table using for all entries applied on the internal table with 80-90 entries...
in short,
it accesses the same database table twice.
so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
is around 80-90 entries too much for using "for all entries"?
the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
i really cant find the way out...
please help.chinmay kulkarni wrote:Chinmay,
Even though you tried to ask the question with detailed explanation, unfortunately it is still not clear.
It is perfectly fine to access the same database twice. If that is working for you, I don't think there is any need to change the logic. As Rob mentioned, 80 or 8000 records is not a problem in "for all entries" clause.
>
> so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
>
It is not clear what you tried to do here. Did you try to bring all 20 million records into an internal table? That will certainly cause the program to short dump with memory shortage.
> the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
>
That is fine. Actually, it is better (performance wise) to do much of the work in ABAP than writing a complex WHERE clause that might bog down the database. -
i have to read an excel sheet from the application server into an internal table that i hv created.can you help me to write select query &read dataset statement?
suppose the internal table name is T_a and it has fields f1 to f7 which are all present in the excel sheet.
<REMOVED BY MODERATOR>
Thanks in advance,
Anand.
Edited by: Alvaro Tejada Galindo on Feb 14, 2008 2:33 PMHi
select f1 f2 f3 f4 f5 f6 f7
from TABLE
into table T_a.
read table T_a with key f1 = <val1>.
<REMOVED BY MODERATOR>
Regards,
Mansi.
Edited by: Alvaro Tejada Galindo on Feb 14, 2008 2:33 PM -
Select Query and Recordset on same page
I have been workig with Coldfusion for a while now. Where I work there is a need for web pages to extract data from data sources. I have been successful at doing this. Typically I use a form that selects multiple criteria, which when submitted loads a target/action page that displays records that are filtered based on the SQL statement contained on that action page. What I do is to conditionally check if criteria is passed using cfif. And if a field parameter is indeed passed it becomes part of the cfquery. This works out well - especially for reporting.
But now I am seeing more and more a need to accomplish the same process - but on a single cfm page. So the page I seek will have both the form (select) and the recordset results on the same page.
In this exercise I will be caching results od a query and having several queries to further refine what I seek (QOQ). What I am seeking is the best practice to follow, I was thinking that using an iframe on the page would be and adequate solution whereby the query would pass the criteria and its form action would pass the variable(s) to the action page, which would be the source of the iframe. But I am not certain that this is a best proctice. Nor have I had great success at getting the pages to work in concert.
Any advice that you can lend would be appreciated.I ideally start by reducing the 2-page functionality - of form page and action page - to just one. It goes like this:
<cfset isValidationPassed = false>
<cfif isDefined("form.someVar")>
<!--- Do validation. Validated form implies isValidationPassed is true --->
</cfif>
<cfif isValidationPassed>
<!--- Do action page stuff --->
<cfelseif NOT isDefined("form.someVar") OR NOT isValidationPassed>
<!--- Display the form. --->
<!--- If form had been submitted, inform user which validation failed, and what to correct. Display the form. --->
<cfoutput><form method="post" action="#CGI.SCRIPT_NAME#"></cfoutput>
</form>
</cfif>
The idea is then to pile on the complexity, layer by layer. -
Select query and Insert statement performance
Hi all,
Can anyone plz guide us on below problem I am facing ?
1) One of the simple Insert statement runs very slow..What might be the reason? Its simple table without any LOBs ,LONG or so. Everything else in the DB works fine.
2) one of the SELECT statement runs very slow. It selects all records (around 1000) from a table..How can i improve its performance?
3)Which columns in the Master and its detail tables should be indexed to improve Query performance on them.
Many Thanks
Regards
sandeepTo get an answer to your questions you have to post some informations about your system:
1. operating system
2. RAM
3. oracle version
4. init.ora
Thomas -
1.1 query builder join between tables
In the latest Sql Developer.
I invoke the query builder and select multiple tables that have foreign keys between them. These foreign key relationships appear in the diagram (good job).
How do I make those relationship appear in the SQL that query builder returns to the sql worksheet. I shouldn't have to re-specify them on the where/criteria tab.
It would be nice if these relationships are defaulted in the joining of tables.I overlayed the pre-release versionsDo you mean you installed in the same directory?
Don't do that.
There's a system directory (sqldeveloper\sqldeveloper\system) which holds settings and everything, which very well might be corrupted to be used for a newer release.
Try deleting it, it will be regenerated at next startup. Or even better: re-install in another directory all together...
K. -
Select query----- inner join codition
i have used below query to get fields from ekpo and eket tables.
i am getting error as the column name 'ebeln' has two meanings.
SELECT A~EBELN
A~EBELP
A~TXZ01
A~MENGE
A~MEINS
A~NETPR
A~NETWR
B~EINDT
FROM EKPO AS A INNER JOIN EKET AS B
ON AEBELN = BEBELN
AND AEBELP = BEBELP
INTO CORRESPONDING FIELDS OF TABLE IT_ITEM
WHERE EBELN = I_EBELN.
please tell what could be the problem
regards,
krishnaHi Krsihna,
refer below code:
WHERE A~EBELN = I_EBELN. or WHERE b~EBELN = I_EBELN..
Thanks
Piyush
Reward Points, if helpfull -
Error in select query using join
hi all
please help.
The follwing code givs this error....
select skb1-bukrs ska1-ktoks skb1-saknr skb1-waers skb1-xsalh skb1-xopvw skb1-xkres
into corresponding fields of table it_skab1
from ( skb1
OUTER JOIN ska1 on ska1-saknr=skb1-saknr ) .
*Error while executing....*
Program ZABHI_FIREPORT
"(" has no closing ")".
Please guide me for the correct syntax.
Thank u.hi,
use this code n check
tables: ska1,skb1.
data: begin of it_skab1 occurs 0,
bukrs like skb1-bukrs,
ktoks like ska1-ktoks,
saknr like skb1-saknr,
waers like skb1-waers,
xsalh like skb1-xsalh,
xopvw like skb1-xopvw,
xkres like skb1-xkres,
end of it_skab1.
select skb1~bukrs
ska1~ktoks
skb1~saknr
skb1~waers
skb1~xsalh
skb1~xopvw
skb1~xkres
from skb1 left outer join ska1 on skb1saknr = ska1saknr
into corresponding fields of table it_skab1 up to 10 rows.
loop at it_skab1.
write: / it_skab1-bukrs,it_skab1-ktoks,it_skab1-saknr,it_skab1-waers,it_skab1-xsalh,
it_skab1-xopvw,it_skab1-xkres.
endloop.
n let me knw is ur doubt cleared
rgds
shivraj
Edited by: ShivrajSinha on May 27, 2009 8:27 AM -
Hi,
I'm creating a query with trx SQ01.
I want to modify the name of a field in the selection screen of the query.
How can I do this ?
RegardsHi,
In SQ01 select query and choose icon "change".
In the change query screen choose from top menu "goto", followed by "field selection" and "selections". In column "No" you can set sequence, in columns "selection text" you can amend the descriptions.
Hope it will solve ur problem -
hi all....
i want to write a select query in workflow to fetch value from a table which i will be saving in workflow container... i cannot create a business object.... what else can i do... i dont hav exp with classes too.... advise some easy way out.....
<Thread moved from ABAP General>
Edited by: Mike Pokraka on Aug 27, 2008 12:47 PMHello Sharma,
Write a program in which you can give your select query and call the FM, SWU_START_WORKFLOW
e.g.:
CALL FUNCTION 'SWU_START_WORKFLOW'
EXPORTING
task = task
* LANGUAGE = SY-LANGU
user = user
* SENDER_ID = SENDER_ID
* IMPORTING
* RETURN_CODE = RETURN_CODE
* WORKITEM_ID = WORKITEM_ID
TABLES
* CONTAINER = CONTAINER
* MESSAGE_LINES = MESSAGE_LINES
attachment_list = attachment_list
Here, in the CONTAINER, pass the workflow container values.
Give the respective task number and user as sy-uname.
Regards
Indu -
SELECT Query design with JOINS
Dear Users,
In one of our requirements, we have a SELECT query which joins a few tables together and selects a few fields from each table.
Example: Fields 1,2 and 3 from Table 1
Fields 4 and 5 from Table 2.
These fields are later displayed in the form of an ALV. However, the end user wants more fields on the output, let's say field 6 from Table 2. Due to this requirement, I have to amend the SELECT query to add field 6 of Table 2.
The above example is simple since it only involves 2 tables. However, in reality, we have a SELECT query with INNER JOINS on more than 6 tables and we don't want to change the code when someone asks for an additional field from one of these tables. Is there any way by which I can design my SELECT query (Using field symbols or dynamic selections etc) such that I don't have to amend the SELECT query and instead I should be able to maintain the field required by the user and it's source table name in a Z-Table and the SELECT automatically picks it up ? Thanks!
Vijaybetter you can create a view on your 6 or more tables and select the fields .
Use Select * from <view name> every time in a select statement.
If you need a additional column then just change the view , there is no need to change of your select query.
with regards
Edited by: Avenai on Jun 28, 2010 2:09 PM
Maybe you are looking for
-
How do I update original software on my iPhone 4 to iOS 5
Is it possible to update my iPhone 4 via wifi the general settings has no "update" option...
-
Hey, Earlier today I clicked on for a FF upgrade. Now I no longer am able to get Skype, and can not access my University of Dallas imba site to listen to today's lecture and access notes etc...crucial...I took the afternoon off from work to do this..
-
Email syncing issues with outlook/entourage/iphone
I am having problems syncing my gmail when using Entourage 2008 on MacBook Pro, Outlook 2010 on Toshiba, and my iphone 3. If I read a message for the first time on my iphone it will not download to outlook. If I read a message for the first time in o
-
Would someone please expatiate on the price disparity between U.S. and Australian iPhone 4S.
-
Low speed of the printing on Inkjet 2800
Hello! I'm guy from Kazakhstan, so sorry for possible grammatical mistakes. We have HP Inkjet 2800 in office. His speed of the printing is very low. Processing lasts around 1 minute... This problem appeared since windows 7 was installed on PC (I'm ca