Doubt in select
hai gurus
i have a doubt
i have a select statement like this
select count(*) into var from emp;
i want to store it into variable.it giving some error;
please give some ideas
thanks
.it giving some error;
please give some ideasHere's an idea. Why don't you cut and paste the code from the session in which you're running. Then we can see the error message it throws and perhaps solve your problem for you.
If you don't give us sufficient details we can't help you. End of.
Cheers, APC
Similar Messages
-
I have a doubt in 'SELECT-CASE'. There is this example of which i have :-
SELECT /*+ rule */ SUM(CASE WHEN age <= 15 THEN cnt ELSE 0 END) "upto 15 Years" ,
SUM(CASE WHEN age >= 16 AND age <= 20 THEN cnt ELSE 0 END) "16-20 Years" ,
SUM(CASE WHEN age >= 21 AND age <= 25 THEN cnt ELSE 0 END) "21-25 Years" ,
SUM(CASE WHEN age >= 26 AND age <= 30 THEN cnt ELSE 0 END) "26-30 Years" ,
SUM(CASE WHEN age >= 31 AND age <= 35 THEN cnt ELSE 0 END) "31-35 Years" ,
SUM(CASE WHEN age >= 36 AND age <= 40 THEN cnt ELSE 0 END) "36-40 Years" ,
SUM(CASE WHEN age >= 41 AND age <= 45 THEN cnt ELSE 0 END) "41-45 Years" ,
SUM(CASE WHEN age >= 46 AND age <= 50 THEN cnt ELSE 0 END) "46-50 Years" ,
SUM(CASE WHEN age >= 51 AND age <= 55 THEN cnt ELSE 0 END) "51-55 Years" ,
SUM(CASE WHEN age >= 56 AND age <= 60 THEN cnt ELSE 0 END) "56-60 Years" ,
SUM(CASE WHEN age >= 61 AND age <= 65 THEN cnt ELSE 0 END) "61-65 Years" ,
SUM(CASE WHEN age >= 66 AND age <= 70 THEN cnt ELSE 0 END) "66-70 Years" ,
SUM(CASE WHEN age > 70 THEN cnt ELSE 0 END) ">70 Years"
FROM
(SELECT /*+ rule */ROUND(MONTHS_BETWEEN(SYSDATE,ca.birthdate)/12) age,COUNT(1) cnt
FROM contract_all co , customer_all ca ,curr_co_status curr
WHERE ca.customer_id = co.customer_id
AND co.co_id = curr.co_id
AND curr.ch_status = 'a'
AND ca.birthdate IS NOT NULL
--AND co.co_activated BETWEEN '01-jan-2004' AND '31-dec-2004'
AND EXISTS ( SELECT 'x' FROM hss_cust_segment hcs
WHERE hcs.prgcode = ca.prgcode
AND hcs.description = 'POST')
GROUP BY ROUND(MONTHS_BETWEEN(SYSDATE,ca.birthdate)/12))
In this the statements on top like this-
SUM(CASE WHEN age >= 16 AND age <= 20 THEN cnt ELSE 0 END) "16-20 Years" ,
how does the increment happen in 'THEN cnt' because we are not doing the increment as such using '+1' kind of thing.
I hope, my question is clear. Please help in solving the doubt.
Regards.Sample data, wrong output and desired output please...
I tried with this and it seems right...
WITH ca as (
select to_date('26-9-1990') birthdate from dual union all
select to_date('26-9-1989') birthdate from dual union all
select to_date('26-9-1974') birthdate from dual
SELECT /*+ rule */ SUM(CASE WHEN age <= 15 THEN cnt ELSE 0 END) "upto 15 Years" ,
SUM(CASE WHEN age >= 16 AND age <= 20 THEN cnt ELSE 0 END) "16-20 Years" ,
SUM(CASE WHEN age >= 21 AND age <= 25 THEN cnt ELSE 0 END) "21-25 Years" ,
SUM(CASE WHEN age >= 26 AND age <= 30 THEN cnt ELSE 0 END) "26-30 Years" ,
SUM(CASE WHEN age >= 31 AND age <= 35 THEN cnt ELSE 0 END) "31-35 Years" ,
SUM(CASE WHEN age >= 36 AND age <= 40 THEN cnt ELSE 0 END) "36-40 Years" ,
SUM(CASE WHEN age >= 41 AND age <= 45 THEN cnt ELSE 0 END) "41-45 Years" ,
SUM(CASE WHEN age >= 46 AND age <= 50 THEN cnt ELSE 0 END) "46-50 Years" ,
SUM(CASE WHEN age >= 51 AND age <= 55 THEN cnt ELSE 0 END) "51-55 Years" ,
SUM(CASE WHEN age >= 56 AND age <= 60 THEN cnt ELSE 0 END) "56-60 Years" ,
SUM(CASE WHEN age >= 61 AND age <= 65 THEN cnt ELSE 0 END) "61-65 Years" ,
SUM(CASE WHEN age >= 66 AND age <= 70 THEN cnt ELSE 0 END) "66-70 Years" ,
SUM(CASE WHEN age > 70 THEN cnt ELSE 0 END) ">70 Years"
FROM ( SELECT /*+ rule */ ROUND(MONTHS_BETWEEN(SYSDATE,ca.birthdate)/12) age, COUNT(1) cnt
FROM ca
GROUP BY ROUND(MONTHS_BETWEEN(SYSDATE,ca.birthdate)/12) )
upto 15 Years 16-20 Years 21-25 Years 26-30 Years 31-35 Years 36-40 Years 41-45 Years 46-50 Years 51-55 Years 56-60 Years 61-65 Years 66-70 Years >70 Years
0 2 0 0 1 0 0 0 0 0 0 0 0
1 rows selectedNH. -
Hi i have a doubt in selection screen I had given statement as below now i can see the output screen and i'm getting the output also now i want to know the value of only one vendor. If i had given a vendor number it must select the particular data of that vendor only can u give me any suggestions please
SELECTION-SCREEN BEGIN OF BLOCK P WITH FRAME TITLE TEXT-000.
PARAMETERS: VENDORNO like EKKo-LIFNR,
PURORG like EKKO-EKORG,
PLANT like EKPO-WERKS,
PURDOC like EKKO-BEDAT.
SELECTION-SCREEN END OF BLOCK P.Hi Pavan,
<b>I think this is what u required when u select vendor number automatically for that particular vendor u require values in the remaining 3 parameter fields.
</b>
REPORT zex31 .
PARAMETERS: vendorno LIKE ekko-lifnr,
purorg LIKE ekko-ekorg,
plant LIKE ekpo-werks,
purdoc LIKE ekko-bedat.
DATA: dynfields TYPE TABLE OF dynpread WITH HEADER LINE.
DATA: return TYPE TABLE OF ddshretval WITH HEADER LINE.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR vendorno.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
tabname = 'EKKO'
fieldname = 'LIFNR'
dynpprog = sy-cprog
dynpnr = sy-dynnr
dynprofield = 'VENDORNO'
TABLES
return_tab = return
EXCEPTIONS
field_not_found = 1
no_help_for_field = 2
inconsistent_help = 3
no_values_found = 4
OTHERS = 5.
BREAK-POINT.
REFRESH dynfields.
READ TABLE return WITH KEY fieldname = 'VENDORNO'.
Add it back to the dynpro.
dynfields-fieldname = return-retfield.
dynfields-fieldvalue = return-fieldval.
APPEND dynfields.
Get the company code from db and add to dynpro
DATA: xekko TYPE ekko,
xekpo TYPE ekpo.
CLEAR xekko.
CLEAR xekpo.
SELECT SINGLE * INTO xekko
FROM ekko
WHERE lifnr = return-fieldval.
dynfields-fieldname = 'PURORG'.
dynfields-fieldvalue = xekko-ekorg.
APPEND dynfields.
dynfields-fieldname = 'PURDOC'.
dynfields-fieldvalue = xekko-bedat.
APPEND dynfields.
SELECT SINGLE * INTO xekpo
FROM ekpo
WHERE ebeln = xekko-ebeln.
dynfields-fieldname = 'PLANT'.
dynfields-fieldvalue = xekpo-werks.
APPEND dynfields.
Update the dynpro values.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-cprog
dynumb = sy-dynnr
TABLES
dynpfields = dynfields
EXCEPTIONS
OTHERS = 8.
START-OF-SELECTION. -
Hai,
I have problem in my select query,
My previous select query:
SELECT rrcty
ryear
rbukrs
rzzpspid
SUM( hslvt )
SUM( hsl01 )
SUM( hsl02 )
SUM( hsl03 )
SUM( hsl04 )
SUM( hsl05 )
SUM( hsl06 )
SUM( hsl07 )
SUM( hsl08 )
SUM( hsl09 )
SUM( hsl10 )
SUM( hsl11 )
SUM( hsl12 )
SUM( mslvt )
SUM( msl01 )
SUM( msl02 )
SUM( msl03 )
SUM( msl04 )
SUM( msl05 )
SUM( msl06 )
SUM( msl07 )
SUM( msl08 )
SUM( msl09 )
SUM( msl10 )
SUM( msl11 )
SUM( msl12 )
FROM zzsl5t
INTO TABLE it_erbproj
WHERE rldnr EQ c_rldnr AND
rrcty EQ c_rrcty AND
ryear EQ v_srr_fyear AND
rbukrs EQ v_srr_ccode AND
racct EQ v_racct AND
rzzpspid IN r_zzpspid
GROUP BY RRCTY ryear RBUKRS rzzpspid.
now i want change the above select query as,
If user enters input period 03 means,
i have to select
SELECT rrcty
ryear
rbukrs
rzzpspid
SUM( hslvt )
SUM( hsl01 )
SUM( hsl02 )
SUM( hsl03 )
SUM( mslvt )
SUM( msl01 )
SUM( msl02 )
SUM( msl03 )
only, not to select all the periods.
how can i give fields dynamically.
please suggest me.
ElamaranDuplicate message. Please close this one and look at my answer Doubt in Select query.
-
Doubt about Select statement.
Hi folks!!
I have a few doubts about the select statements, it may be a silly things but its useful for me.
what is difference between below statment.
1)SELECT * FROM TABLE.
2)SELECT SINGLE * FROM TABLE
3)SELECT SINGLE FROM TABLE.
Hope i will get answer,thanks in advance.
Regards
Richie..Hi,
try this and if possible use sap help.i mean place the cursor on select and press F1.
Types of select statements:
1. select * from ztxlfa1 into table it.
This is simple select statement to fetch all the data of db table into internal table it.
2. select * from ztxlfa1 into table it where lifnr between 'V2' and 'V5'.
Thisis using where condition between v2 and v5.
4. select * from ztxlfa1 where land1 = 'DE'. "row goes into default table work Area
5. select lifnr land1 from ztxlfa1
into corresponding fields of it "notice 'table' is omitted
where land1 = 'DE'.
append it.
endselect.
Now data will go into work area. and then u will add it to internal table by
append statement.
6. Table 13.2 contains a list of the various forms of select as it is used with internal tables and their relative efficiency. They are in descending order of most-to-least efficient.
Table 13.2 Various Forms of SELECT when Filling an Internal Table
Statement(s) Writes To
select into table it Body
select into corresponding fields of table it Body
select into it Header line
select into corresponding fields of it Header line
7. SELECT VBRK~VBELN
VBRK~VKORG
VBRK~FKDAT
VBRK~NETWR
VBRK~WAERK
TVKOT~VTEXT
T001~BUKRS
T001~BUTXT
INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
FROM VBRK
INNER JOIN TVKOT ON VBRKVKORG = TVKOTVKORG
INNER JOIN T001 ON VBRKBUKRS = T001BUKRS
WHERE VBELN IN DOCNUM AND VBRK~FKSTO = ''
AND VBRK~FKDAT in date.
Select statement using inner joins for vbrk and t001 and tvkot table for this case based on the conditions
8. SELECT T001W~NAME1 INTO TABLE IT1_T001W
FROM T001W INNER JOIN EKPO ON T001WWERKS = EKPOWERKS
WHERE EKPO~EBELN = PURORD.
here selecting a single field into table it1_t001winner join on ekpo.
9. SELECT BUKRS LIFNR EBELN FROM EKKO INTO CORRESPONDING FIELDS OF IT_EKKO WHERE EBELN IN P_O_NO.
ENDSELECT.
SELECT BUTXT FROM T001 INTO IT_T001 FOR ALL ENTRIES IN IT_EKKO WHERE BUKRS = IT_EKKO-BUKRS.
ENDSELECT.
APPEND IT_T001.
here I am using for all entries statement with select statement. Both joins and for all entries used to fetch the data on condition but for all entries is the best one.
10. SELECT AVBELN BVTEXT AFKDAT CBUTXT ANETWR AWAERK INTO TABLE ITAB
FROM VBRK AS A
INNER JOIN TVKOT AS B ON
AVKORG EQ BVKORG
INNER JOIN T001 AS C ON
ABUKRS EQ CBUKRS
WHERE AVBELN IN BDOCU AND AFKSTO EQ ' ' AND B~SPRAS EQ
SY-LANGU
AND AFKDAT IN BDATE AND AVBELN EQ ANY ( SELECT VBELN FROM
VBRP WHERE VBRP~MATNR EQ ITEMS ).
Here we are using sub query in inner join specified in brackets.
Thanks,
chandu. -
Hi gurus,
I done one report to get the Purchase order details. At the time of creating purchase order the users enters a One text field in the Purchase order header text of ME21N transaction. I need to fetch that field into Report. Upto this its fine. I also done this report by using the function module "READ_TEXT". The o/p is also generated successfully.
But now our client is asking, Please put that text field in selection-screen. Once he presses F4 in that field he needs to display all the values in text field. I know how to do if it is a table field. But it is a purchase order header text. Client enters different text when he creates diferent purchase orders.
Based on that text field only the report o/p will needs to display.
For example:
The User1 creats a Purchase order using ME21N. In that he enters Purchase order header text as ABC.
when ever he creats a purchase order he enters only ABC.In this way he creats 100 Purchase orders.
if the user execute the report and in selection screen of that text field , suppose he gives a ABC, only those 100 purchase orders only needs to appear.
Like this so many users enters no.of text items. Suppose there are 100 users. totally 100 text values will be there.
once he presses F4 help on the selecton screen all 100 values need to display. And this is dynamic, the no may increase in future also. thats totally depends on Purcase orders.
Please guide me how to do this.
Thanks in Advance...
Thanks and Regards
Siri........hi frnd,
try like this
write the logic to fetch text fields into some internal table in
at selection-screen output event.
and pass this to selection-option as f4 using ...> call function 'F4IF_INT_TABLE_VALUE_REQUEST'.
ex
at selection-screen output.
use fm "READ_TEXT". and assign all values to one internal table
then
call function 'F4IF_INT_TABLE_VALUE_REQUEST'.
hope it may help u.
regards,
chandu -
Simple doubt in select statement
hi all,
Although this is a very simple ques.
Can u pl tell me why i m not getting the value into v_adrnr ?
Chk the following code.
V_VBELN = '0080000001'.
SELECT SINGLE ADRNR
FROM VBPA
INTO V_ADRNR
WHERE VBELN = V_VBELN
AND PARVW = 'BP'.
i have cheked the table vbpa for the above mentioned conditions.I can see the
value for adrnr in database as 0000022741.
But while i run the above code i cant see value on v_adrnr.
Pl help.First PARVW has a domain with a conversion routine based on table TPAUM so "BP" is internal code "RE"
Use CONVERSION_EXIT_PARVW_INPUT
CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
EXPORTING
input = V_PARVW
IMPORTING
output = V_PARVW.
Second
Have you defined V_VBELN with reference to the element VBELN, char 10 with conversion Alpha
Then it should work
Regards -
Hi :
How can i join aufnr , arbei , ismnw since there is no common key field between arbei and aufnr , ismnw.
I am able to join aufnr and ismnw based on aufnr, because im trying to pull data based on aufnr , but when i went to se84 and tried to chk tables for arbei...only one table HIKO has all these fields but there is no data in that.
SELECT aaufnr aauart b~arbei INTO CORRESPONDING FIELDS OF TABLE it_tab
FROM aufk AS a
INNER JOIN plpo AS b ON awerks = bwerks
INNER JOIN iloa AS d ON abukrs = dbukrs
*06/18
INNER JOIN afko AS e ON aaufnr = eaufnr
WHERE a~auart IN s_auart
AND a~auart NE 'PM04'
AND a~auart NE 'PM09'
AND a~werks = 'M600'
AND d~tplnr = 'PB-PRO-S01-BY02-MIL'
AND d~abckz IN s_abckz
AND a~erdat IN s_date.
SELECT SINGLE ismnw INTO v_ismnw FROM afru
WHERE aufnr = v_aufnr.
it_tab-ismnw = v_ismnw.
with my first select statment do i get unique values for arbei?
i would appreciate if any one can help me on this.
Thanks.
RaghuEverybody's question is important.
All you have to do is edit your original question and it will pop to the top.
If you ask the same question twice, somebody may spend a lot of time trying to answer your question only to find that someone else answered it a long time before.
Rob -
Hi all!
I have to show the inspection lot details (QA32) as per the requirements given in the selection screen.
In my selection screen , I should have select option for Inspection lot created date(QALS-ENSTEHDAT) and lot created time (QALS-ENTSTEZEIT). I would like to know the lots created from yesterday evening till today morning.
When I give the values 09.02.2008 to 10.02.2008 for date and 17:30:00 to 10:00:00 for time , it'll obviously intimate that 'From- time is greater than To- time'.Is there any way to relate the From-date to From-time and To-date to To-time in the selection screen , so that my problem will be solved.Please help with possible code.
Edited by: Jayasri P. on Feb 9, 2008 5:55 AMHi,
try this.........
TABLES qals.
DATA it_qals TYPE TABLE OF qals WITH HEADER LINE.
SELECT-OPTIONS s_date FOR qals-enstehdat NO-EXTENSION.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN comment (10) for field p_timel.
SELECTION-SCREEN POSITION 35.
PARAMETERS p_timel LIKE qals-entstezeit.
SELECTION-SCREEN comment 54(2) for field p_timeh.
SELECTION-SCREEN POSITION 60.
PARAMETERS p_timeh LIKE qals-entstezeit.
SELECTION-SCREEN END OF LINE.
SELECT *
FROM qals
INTO TABLE it_qals
WHERE enstehdat IN s_date.
IF sy-subrc IS INITIAL.
SORT it_qals BY enstehdat entstezeit.
LOOP AT it_qals WHERE enstehdat EQ s_date-low
OR enstehdat EQ s_date-high.
CASE it_qals-enstehdat.
WHEN s_date-low.
IF it_qals-entstezeit LT p_timel.
DELETE it_qals.
ENDIF.
WHEN s_date-high.
IF it_qals-entstezeit GT p_timeh.
DELETE it_qals.
ENDIF.
ENDCASE.
ENDLOOP.
ENDIF.
LOOP AT it_qals.
WRITE : / it_qals-enstehdat ,it_qals-entstezeit.
ENDLOOP.
also goto selection text and give descriptionas below..
P_TIMEH to
P_TIMEL Time
S_DATE Date
Cheers,
jose. -
Doubt in select [Resolved]
Hello, I need urgent help
I have a table where two fields are repeated
id_terr, resource_id. For example:
id | id_terr | resource_id
01 | 500 | 100900
02 | 505 | 100900
03 | 513 | 100900
04 | 718 | 108000
05 | 650 | 108000
06 | 513 | 108000
07 | 500 | 108000
08 | 800 | 115000
09 | 650 | 115000
I need to select all the fields but only one record at a resource_id, leave with this result for example
id | id_terr | resource_id
01 | 500 | 100900
04 | 718 | 108000
08 | 800 | 115000
Can anyone help me select this?
Could it?
Thanks
Cristian
Edited by: Munhoz on 25/09/2009 08:46with t as (
select '01' id,500 id_terr,100900 resource_id from dual union all
select '02',505,100900 from dual union all
select '03',513,100900 from dual union all
select '04',718,108000 from dual union all
select '05',650,108000 from dual union all
select '06',513,108000 from dual union all
select '07',500,108000 from dual union all
select '08',800,115000 from dual union all
select '09',650,115000 from dual
select min(id) id,
min(id_terr) keep (dense_rank first order by id) id_terr,
resource_id
from t
group by resource_id
order by resource_id
ID ID_TERR RESOURCE_ID
01 500 100900
04 718 108000
08 800 115000
SQL> SY.
Edited by: Solomon Yakobson on Sep 24, 2009 6:28 PM -
Doubt in SELECT query (11.2.0.2.0)
I have 3 tables
1. ADBO.SECMASTER_DTL_EXT_HST_TBL
2. BDBO.SECMASTER_DETAIL_EXT_HIST
3. ADBO.SPOKE_TO_HUB_SEC_MTCH_TBL
ADBO.SECMASTER_DTL_EXT_HST_TBL and BDO.SECMASTER_DETAIL_EXT_HIST have exactly the same table structure.
Now, I need to find out the records from table BDO.SECMASTER_DETAIL_EXT_HIST with the max effective_date
which do not match to the effective_date in ADBO.SECMASTER_DTL_EXT_HST_TBL. In the results table I need to report the diff effective dates from the 2 tables if they do not match.
Also, SRC_INTFC_INST has to be 140 in both 1 and 2 tables. Further security_alias of table 1 has to match with spoke_sec of table 3
and security_alias of table 2 has to match with hub_sec of table 3.
For the data I have , I am getting 2 rows whereas I am expecting only 1 row. Can anyone suggest why this is so??
SELECT
B.SECURITY_ALIAS,
TO_CHAR (C.SPOKE_PAID),
A.SECURITY_ALIAS,
TO_CHAR (C.HUB_PAID),
'SECMASTER_DETAIL_EXT_HIST',
'EFFECTIVE_DATE',
NVL ( (CAST (B.EFFECTIVE_DATE AS VARCHAR2 (100))),
'No Records Found'),
NVL ( (CAST (A.EFFECTIVE_DATE AS VARCHAR2 (100))),
'No Records Found')
FROM ADBO.SECMASTER_DTL_EXT_HST_TBL A,
(SELECT SECURITY_ALIAS, EFFECTIVE_DATE, SRC_INTFC_INST
FROM [email protected]) B,
ADBO.SPOKE_TO_HUB_SEC_MTCH_TBL C
WHERE A.SRC_INTFC_INST = 140
AND B.SRC_INTFC_INST = 140
AND A.SECURITY_ALIAS = C.spoke_sec
AND b.security_alias = C.HUB_SEC
AND TO_CHAR (a.effective_date,'DD-MON-YYYY')
<> TO_CHAR((SELECT MAX (h.effective_date)
FROM [email protected] H
where h.security_alias = b.security_alias
AND h.src_intfc_inst = b.src_intfc_inst), 'DD-MON-YYYY')
and a.security_alias='6313';
Insert into ADBO.SECMASTER_DTL_EXT_HST_TBL
(SECURITY_ALIAS, SRC_INTFC_INST, EFFECTIVE_DATE)
Values
(6313, 140, TO_DATE('05/15/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into BDBO.SECMASTER_DETAIL_EXT_HIST
(SECURITY_ALIAS, SRC_INTFC_INST, EFFECTIVE_DATE)
Values
(327667, 140, TO_DATE('05/20/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into BDBO.SECMASTER_DETAIL_EXT_HIST
(SECURITY_ALIAS, SRC_INTFC_INST, EFFECTIVE_DATE)
Values
(327667, 140, TO_DATE('05/15/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into ADBO.SPOKE_TO_HUB_SEC_MTCH_TBL
(SPOKE_PAID, SPOKE_SEC, LAST_HELD_DATE, PREV_HELD_DATE, HUB_PAID, HUB_SEC)
Values
('L3083 ', 6313, TO_DATE('07/18/2013 22:15:46', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('07/15/2013 22:15:30', 'MM/DD/YYYY HH24:MI:SS'), 'L3083 ',
327667);
CREATE TABLE ADBO.SECMASTER_DTL_EXT_HST_TBL
SECURITY_ALIAS NUMBER NOT NULL,
SRC_INTFC_INST NUMBER NOT NULL,
EFFECTIVE_DATE DATE NOT NULL
CREATE TABLE BDBO.SECMASTER_DETAIL_EXT_HIST
SECURITY_ALIAS NUMBER,
SRC_INTFC_INST NUMBER,
EFFECTIVE_DATE DATE
CREATE TABLE ADBO.SPOKE_TO_HUB_SEC_MTCH_TBL
SPOKE_PAID VARCHAR2(100 BYTE),
SPOKE_SEC NUMBER,
LAST_HELD_DATE DATE,
PREV_HELD_DATE DATE,
HUB_PAID VARCHAR2(100 BYTE),
HUB_SEC NUMBERHi,
one suggestion. Don't include schema in the table.
I have created your tables in my db with the following names:
a_secmaster_dtl_ext_hst_tbl
b_secmaster_detail_ext_hist
spoke_to_hub_sec_mtch_tbl
You query may be solved in this way maybe, according to what I have understood in the previous post.
with table_a as
select a.security_alias
, c.spoke_paid
, c.hub_paid
, a.effective_date
from a_secmaster_dtl_ext_hst_tbl a
join spoke_to_hub_sec_mtch_tbl c
on (a.security_alias=c.spoke_sec)
where a.src_intfc_inst = 140
and a.effective_date = (select max(a2.effective_date)
from a_secmaster_dtl_ext_hst_tbl a2
where a.security_alias=a2.security_alias
and a.src_intfc_inst=a2.src_intfc_inst)
, table_b as
select b.security_alias
, c.spoke_paid
, c.hub_paid
, b.effective_date
from b_secmaster_detail_ext_hist b
join spoke_to_hub_sec_mtch_tbl c
on (b.security_alias=c.hub_sec)
where b.src_intfc_inst = 140
and b.effective_date = (select max(b2.effective_date)
from b_secmaster_detail_ext_hist b2
where b.security_alias=b2.security_alias
and b.src_intfc_inst=b2.src_intfc_inst)
select b.security_alias
, a.spoke_paid
, a.security_alias
, b.hub_paid
, 'SECMASTER_DETAIL_EXT_HIST' txt1
, 'EFFECTIVE_DATE' txt2
, nvl(to_char(b.effective_date,'dd-mon-yyyy'), 'No Records Found') b_eff_date
, nvl(to_char(a.effective_date,'dd-mon-yyyy'), 'No Records Found') a_eff_date
from table_a a full outer join table_b b on(a.spoke_paid=b.hub_paid)
where a.effective_date!=b.effective_date;
I have used full outer join to join the table to cover the case where records are present in table a and not in table b and the opposite.
Regards.
Alberto -
Hello Every1,
I have a select option field for which the input values can be given as in the below example.
Ex. If the input value is given as 10* as the low value and 100* as the high value, i need to fetch records in this range.Which means it should not only include all values starting with 10 and 100 but also the values between 10 and 100. Please let me know how this can be achieved.
Best Regards,
Siva.Hi Siva,
Why dont you have a try by putting % instead of *
Just its a try...
Cheers,
Sampath -
Hi frnds,
Normally select option allowing only 8 charactor in declaration part, but i want to display with morethan 8 charator. i think some text id formet is there, how to do that.
for ex,
s_org for vbak-vkorg .
for this i want to give sales organisation.
how to do this.
plz its urgent.
GowriSELECTION-SCREEN BEGIN OF LINE.
[SELECTION-SCREEN POSITION pos [ldb_additions]].
SELECTION-SCREEN END OF LINE.
Effect
The first and last statements define a new line below the existing elements on the selection screen.
All the screen elements within these statements that are defined with PARAMETERS SELECT-OPTIONS and SELECTION-SCREEN statements are placed in this line one after the other without spaces.
Several SELECTION-SCREEN POSITION statements can be listed within the definition of a line. The SELECTION-SCREEN POSITION statement can be used to define the output position for the following screen element. The position pos can either be specified directly as a number between 1 and 83 or using pos_low or pos_high expressions. The expression pos_low specifies the position in which the input field for a parameter or the first input field for a selection criterion is displayed as standard. The expression pos_high specifies the position in which the second input field for a selection criterion is to be displayed as standard. If you make a different specification of the position in the statement defining the following element, this is taken into account. The statement SELECTION-SCREEN POSITION is only possible within the definition of a line. If there are conflicts with existing screen elements, the selection screen cannot be generated.
The additions ldb_additions can only be used in a selection include for a logical database.
The following applies in the definition of a line:
Output fields are not created for selection texts for the parameters displayed in these kinds of lines. Instead, these can be created by specifying a SELECTION-SCREEN COMMENT.
You cannot define other lines with SELECTION-SCREEN BEGIN OF LINE.
You cannot define blocks or tabstrip controls with SELECTION-SCREEN BEGIN OF [TABBED] BLOCK.
Within a line, only one selection criteria should be defined with SELECT-OPTIONS whose description can be specified in advance using SELECTION-SCREEN COMMENT. Other combinations, especially definitions of elements according to the selection criteria, can lead to an undefined behaviour.,
The backslash (/) is not allowed when giving format specifications.
You can omit the position specification pos in formatting specifications.
Note
If a screen element is assigned a position greater than 83 or is positioned outside a block with a frame, the selection screen is not generated. In the case of input and output fields that were positioned beforehand but have a length that extends beyond the end of the line, the visible length is shortened accordingly and the content is displayed in the visible length and can be scrolled. In this case, pushbuttons and horizontal lines are cut off at position 83 or where the frame of the block ends.
Example
A pushbutton, an input field, and an output field in a line in the standard selection screen for an executable program.
SELECTION-SCREEN: BEGIN OF LINE,
PUSHBUTTON 2(10) push USER-COMMAND fcode,
POSITION 16.
PARAMETERS para TYPE c LENGTH 20.
SELECTION-SCREEN: COMMENT 40(40) text,
END OF LINE.
INITIALIZATION.
push = 'Push'.
text = '<--- Fill field, then push button!'. -
Hi,
I created a new table 'STUD' with columns 'STUD_NO','STUD_NAME' and 'FEES' in it.
I inserted the data
insert into stud values (001,'xxxx',2000);
insert into stud values (002,'yyyy',3000);
when I selecting the data using SELECT statement...
it is retreving as
STUD_NO STUD_NAME FEES
1 xxxx 2000
2 yyyy 3000
my question is I inserted it the way as '001' but I am retreiving it as '1'......
Is there any way that I can retreive the data the same way(001) I have entered for STUD_NO column.
Means i need to get it as '001' only...
Can anyone please solve this.
Thanks in advance.Here if we see we are not directly retreving the same way as it from table.
we are formating it to 'FM000' means limited to three numerics as we know that it is 001.
But if I dont know exact value as above and still I want to retreive the sameway as it is from databse.
Is there otherway to do this.
Here I have given the value as 001 and u have mentioned it to give as 'FM000'.
But If I dont know the value and still I want to select the data as it is how I can do.
Thanks in advance. -
HI Friends,
i have a requirement to select matnr,werks and mmsta from marc table.where i have input of matnr and mmsta.
The matnr in the marc table having 2 werks with different mmsta.
i was asked to select matnr not having mmsta 40.
but in marc table there is same matnr with two mmsta 37 and 40.
i want a select statement which should not pick matnr having 40.
my select statement was
select matnr werks mmsta into itab from marc
where matnr in fpso_matnr and mmsta in fpso_mmsta.
this does not work for the above condition.
please suggest me a correct statement..
Thanks,
Gokulselect matnr werks mmsta into itab from marc
where matnr in fpso_matnr and mmsta in fpso_mmsta
and mmsta NE 40.
ill this not work ?
MARC is plant data.. so I guess u need to give werks also...
Edited by: jackandjay on Dec 19, 2007 12:02 PM
Maybe you are looking for
-
Error in phase START_SHDI_FIRST during upgrade to ECC6
Hi Expert, When I upgrade from R3 46C to ECC6NU on Windows server 2003 64bits with SQL SERVER 2005 64bits, in phase START_SHDI_FIRST, it is failed. Here is the log: trc file: "dev_w21", trc level: 1, release: "700" ACTIVE TRACE LEVEL 1 ACTI
-
Download assistant \\ Adobe Premiere \\ why nothing appears in dialog box?
Why nothing appears in dialog box while using Adobe Download Assitant & already logged in. I chose "video" products but it keeps being empty.
-
Nokia Music Service Unavailible
On my Lumia 920 and my daughters Lumia 820 we cant play any music from the Nokia Music service. It previously worked. We have tried with WiFi and Cellular conections. The service appears down. When we go to a mix radio station the first song comes
-
I recently bought an iPad mini online in which I had to type in the previous apple Id in which was used to set it up. I absolutely have no idea what to do and searched online to see what i can do and I was told to speak to apple. Can you please repl
-
Create Purchase Requistions through MD01 despite Procurement Type X
Hi, When we run MD01, Planned Orders are being created for our materials with Procurement Type X despite we select "1 - Purchase Requisitions" in field "Create Pruchase req." We would like to have Purchase Requisitions created instead of Planned Orde