Question: I have a requirement where in i need to find the lowest and non repeating value in a sql column. Let me describe it

```
Sno. User amount
1.   1001 $0.02
2.   1002 $0.03
3.   1003 $0.04
5.   1004 $0.02
6.   1005 $0.05

```

In this scenario, in the amount column although $0.02 is the minimum, but we can see that it is also preset twice(repeating) in the column, so the next minimum and non repeating value is $0.03 and which is what I want.
I tried using Distinct but it gives all the values in the amount column I just need the one. I don't care about the higher values $0.04 and $0.05 here.

Answer: 
What you need is *conditional aggregation*:

```
select ......,   sum(case when amount < 0 then amount end) as credits,
                 sum(case when amount > 0 then amount end) as debits
from   ......
group by account_number

```
I would suggest something like that:

```
SELECT account,
       sum((amount>0)*amount) as debit, 
       sum((amount<0)*amount) as credit
FROM table
GROUP BY account

```