A database table contains 3
fields(Student_no,Section,Total_marks).I want retrieve top 10
students from each section.Note:(Section contains data like
A,B,C.Each section contains more than 10 students).
Answers were Sorted based on User's Feedback
Answer / anonymous
Those mark the answer as No. pls provide the right answer
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sivaramakrishna
according to our requirment
get allthe records using select * from st_db into stu_itab1.
1.first sort the stu_itab1 by marks field.
now use the select single section from st_db into stu_itab2.
now we have to use select for all entries as below.
select section marks from stu_itab1 into table stu_itab3
for all entries in stu_itab2 upto 10 rows.
it may be not exact . but do try in this way
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / waseem
**Sorry guys for above wrong code which I posted, You can **use this code with 100 % result****
tables : ywt_student, ywt_result.
data : begin OF itab OCCURS 0, "structure from 2 tables
usn like ywt_student-usn,
name like ywt_student-name,
dob like ywt_student-dob,
cls like ywt_result-class,
marks like ywt_result-marks,
end of itab.
**"selecing values from 2 tables*****
select ywt_student~usn name dob class marks
INTO TABLE itab
from ywt_student INNER JOIN ywt_result on ywt_student~usn = ywt_result~usn.
**Sorting for testing Perpose*****
sort itab by cls ASCENDING marks DESCENDING.
LOOP AT itab.
on CHANGE OF itab-cls.
skip.
ENDon.
WRITE :/ itab-usn, itab-name, itab-dob, itab-cls, itab-marks.
ENDLOOP.
skip 2.
***Actual Logic of Requirement***
data : m LIKE ywt_result-marks.
data : count TYPE i value 0.
CLEAR itab.
sort itab by cls ASCENDING marks DESCENDING.
CLEAR itab.
LOOP AT itab.
m = itab-marks.
on CHANGE OF itab-cls.
skip 2.
count = 0.
ENDon.
AT NEW cls.
itab-marks = m.
count = count + 1.
IF count LE 10.
WRITE :/ itab-usn, itab-name, itab-dob, itab-cls, itab-marks.
CLEAR itab.
ENDIF.
ENDAT.
ENDLOOP.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / shaheen
This can be achived by '...group by' addition in the select
statement.
Regards,
Shaheen
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / sateesh
for this initially we can SORT in assending order,
then using "select up to 10 rows".
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / waseem
DATA itab LIKE zabc OCCURS 10 WITH HEADER LINE.
SELECT * FROM zbad5 INTO TABLE itab.
SORT itab BY sclass smarks.
data : count type i value 0.
LOOP AT itab.
AT NEW sclass.
count = count + 1.
IF ( count LE 10 ).
WRITE: / itab."-sno1, itab-sclass, itab-smarks.
ENDIF.
ENDAT.
AT END of sclass.
count = 0.
ENDAT.
ENDLOOP.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / balamurugan
REPORT zscenario.
DATA itab LIKE zabc OCCURS 10 WITH HEADER LINE.
SELECT * FROM zbad5 INTO TABLE itab.
SORT itab BY sclass smarks.
LOOP AT itab.
AT NEW sclass.
WRITE: / itab."-sno1 itab-sclass itab-smarks.
ENDAT.
This display the report based upon the class.But i don't know how to retrieve 10 records from each class.
ENDLOOP.
| Is This Answer Correct ? | 0 Yes | 2 No |
How do you get your task to perform?
What is a type-pool?
1) How to maintain lists in dialog programming? 2)How to send greeting with different languages to different regions in smartforms? 3)Can we transfer 100 screen data to pass 200 screen? 4)In reports 1st list o/p can be consider as i/p of 2nd list how it maintains? 5) In lsmw data length 20 chars only but there is 24 chars field how can u manage? 6)What is the diff b/w OK_CODE n SY_UCOMM?
Can we create a field without data element ? If yes what is the difference?
What are the problems in processing batch input session?
How to debug an Idoc at runtime?
Have you printed any report?
What is SAP Data conversion ?
How do you see the data in a table?
Urgent Openings for Professionals with 4+ yrs in SAP ABAP HR, for a Reputed CMM Level V Organization in Hyderabad
when we create a simple report with input field as S_VBELN (as select-options)..for any range of values it is displaying the output...i dont want like that..only the existing ranges it must be displayed...for ex. in sales ranges from 4969...but in input from 1 to z also displaying..please send me the solution
to explicititly intialize the selection screen for each call you must you the event ________________?
SAP Basis (1262)
SAP ABAP (3939)
SAPScript (236)
SAP SD (Sales & Distribution) (2717)
SAP MM (Material Management) (912)
SAP QM (Quality Management) (99)
SAP PP (Production Planning) (523)
SAP PM (Plant Maintenance) (252)
SAP PS (Project Systems) (138)
SAP FI-CO (Financial Accounting & Controlling) (2766)
SAP HR (Human Resource Management) (1180)
SAP CRM (Customer Relationship Management) (432)
SAP SRM (Supplier Relationship Management) (132)
SAP APO (Advanced Planner Optimizer) (92)
SAP BW (Business Warehouse) (896)
SAP Business Workflow (72)
SAP Security (597)
SAP Interfaces (74)
SAP Netweaver (282)
SAP ALE IDocs (163)
SAP Business One (110)
SAP BO BOBJ (Business Objects) (388)
SAP CPS (Central Process Scheduling) (14)
SAP GTS (Global Trade Services) (21)
SAP Hybris (132)
SAP HANA (700)
SAP PI (Process Integration) (113)
SAP PO (Process Orchestration) (25)
SAP BI (Business Intelligence) (174)
SAP BPC (Business Planning and Consolidation) (38)
SAP BODS (Business Objects Data Services) (49)
SAP BODI (Business Objects Data Integrator) (26)
SAP Ariba (9)
SAP Fiori (45)
SAP EWM (Extended Warehouse Management) (58)
Sap R/3 (150)
SAP FSCM Financial Supply Chain Management (101)
SAP WM (Warehouse Management) (31)
SAP GRC (Governance Risk and Compliance) (64)
SAP MDM (Master Data Management) (0)
SAP MRS (Multi Resource Scheduling) (0)
SAP ESS MSS (Employee Manager Self Service) (13)
SAP CS (Customer Service) (0)
SAP TRM (Treasury and Risk Management) (0)
SAP Web Dynpro ABAP (198)
SAP IBP (Integrated Business Planning) (0)
SAP OO-ABAP (Object Oriented ABAP) (70)
SAP S/4 HANA Finance (Simple Finance) (143)
SAP FS-CD (Collections and Disbursements) (0)
SAP PLM (Product Lifecycle Management) (0)
SAP SuccessFactors (33)
SAP Vistex (0)
SAP ISR (IS Retail) (28)
SAP IdM (Identity Management) (0)
SAP IM (Investment Management) (0)
SAP UI5 (59)
SAP SCM (Supply Chain Management) (51)
SAP XI (Exchange Infrastructure) (49)
SAP Cloud Platform (34)
SAP Testing (89)
SAP SolMan (Solution Manager) (63)
SAP MaxDB (116)
SAP GUI (15)
SAP AllOther (329)