Note that there are some explanatory texts on larger screens.

plurals
  1. POOracle PL/SQL Query
    primarykey
    data
    text
    <p>The code is working but the top (X) TOP PRICE are not fetched accordingly. How do I use Ties with my code ?<br> Some of the top (x) are ignored.</p> <p>This is my table </p> <pre><code> STAFF_NUMBER STAFF_NAME PRICE ------------ ----------------------------------------- ---------- 36 Helen Hilfg 330066 52 Octavia Chan 356885 36 Helen Hilfg 176088 4 Heidi Lee 231046 6 Jill Murphy 469844 32 Lily Roy 247549 58 John Roy 309299 </code></pre> <p>This is what I am getting </p> <pre><code> SQL&gt; SQL&gt; SQL&gt; exec p4(3) PERSON# NAME 36 Helen Hilfg 52 Octavia Chan 4 Heidi Lee </code></pre> <p>This is what I suppose to get </p> <pre><code> SQL&gt; exec p4(3); PERSON# NAME -------------------- 36 Helen Hilfg 6 Jill Murphy 52 Octavia Chan </code></pre> <p>Here is my procedure</p> <pre><code>CREATE OR REPLACE PROCEDURE p3( X NUMBER ) AS staff_number NUMBER ; staff_name VARCHAR2(30) ; CURSOR c1 IS SELECT staff_number, staff_name FROM (SELECT P.peid staff_number, P.firstname || ' ' || P.lastname staff_name , D.price PRICE FROM Contact C, Deal D, Person P, Staff S WHERE S.peid = C.peid AND C.pno = D.pno AND P.peid = C.peid AND (SYSDATE - D.day &lt; 365)) WHERE ROWNUM &lt;= X GROUP BY staff_name , staff_number ORDER BY SUM( price ) DESC ; BEGIN dbms_output.put_line( ' PERSON# ' ||' '||' NAME ' ); FOR R IN c1 LOOP staff_number := R.staff_number ; staff_name := R.staff_name ; dbms_output.put_line( staff_number ||' '|| staff_name ) ; END LOOP ; END; / </code></pre> <p>The code is working but the top (X) TOP PRICE are not fetched accordingly. How do I use Ties with my code ?<br> Some of the top (x) are ignored.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload