skip to Main Content

Lets say I have a table of: order_id, agent_name, order_amount.

order_id agent_name order_amount
1 Justin 500
2 Justin 500
3 Justin 1000
4 Justin 1000
5 Pablo 750
6 Dinesh 500

How would I write a query to apply DISTINCT not only on agent_name but also on order_amount? Basically want it to return [Justin, 500] and [Justin, 1000] once only. Is it something like the below:

SELECT DISTINCT agent_name, 
DISTINCT order_amount
FROM table

2

Answers


  1. The query goes like this:

    SELECT DISTINCT agent_name, order_amount FROM table
    

    Hope this helps. Thanks.

    Login or Signup to reply.
  2. You can simply use

    SELECT DISTINCT agent_name, order_amount
    FROM table
    

    DISTINCT applies to all columns listed in select.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search