Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: EXISTS 2 Jump to:  
Category: >> Oracle PL/SQL >> EXISTS 2 Bookmark and Share

<< lastnext >>

Snippet Name: EXISTS 2

Description: Another example of the use of the 'EXISTS' clause.

Also see:
» AND Condition
» Distinct
» Having Clause
» EXISTS
» WITH with CONNECT BY
» WITH Clause: Single alias
» WITH Clause: Double alias

Comment: (none)

Language:
Highlight Mode: PLSQL
Last Modified: March 01st, 2009

SELECT DISTINCT(aps.customer_id), 
       rc.customer_number,
       rc.customer_name,
       SUM(aps.amount_due_remaining)
FROM ar_payment_schedules aps, ra_customers rc 
WHERE aps.customer_id = rc.customer_id
  AND aps.class IN ('CM', 'PMT', 'INV')
  AND aps.status = 'OP'
  AND EXISTS (
         SELECT a.customer_id
         FROM ar_payment_schedules a
         WHERE a.customer_id = aps.customer_id
           AND aps.status = 'OP'
           AND aps.class IN ('CM', 'PMT', 'INV')
           AND TO_CHAR(aps.trx_date, 'J') <= '30-SEP-95' 
         GROUP BY aps.customer_id)
GROUP BY aps.customer_id, rc.customer_number, rc.customer_name;


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 295 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?