Thursday 15 September 2011

oracle - SQL Query to evaluate multiple rows -


I want to get only the customers from the order table who have paid all the orders (paid = 'y' ).

The order table looks like this:

  Customer # Order # Paid 111 1 Y 111 2Y 222 3Y 222 4N 333 5N   

In this example, the query should return only the customer 111.

query

  select from that order * where paid = 'y';   

In addition to the payment to the customers who have paid for all their orders (customer 111), the payment and unpaid orders (eg, customer 222) get returns.

How can I configure a query to evaluate all orders for a customer and return the information for the paid customer only for all orders?

Looking at the problem in a different way, you only need those customers who have no unpaid orders is not.

  Minimum (paid) = 'Y' in group by group;   

The above question also uses the fact that 'Y' & gt; 'N'.

SQL BADAL:

If you need to select all different orders for eligible customers, then you can use the OLP functions: Order, paid (order, order, payment, more than min (payment) by order (by order cus) by minz) dt where minz = 'Y';

No comments:

Post a Comment