I have a table "Invoice" 

```
id integer Primary key
customer_id Integer
total Number (*,2)

```

The query is to display all customer\_id, total and running serial number to each customer with alias name as 'SNO'. And the records should be displayed in ascending order based on the customer\_id and then by SNO.

Hints:

* Analytic Function: ROW\_NUMBER( )
* Analytic Clause: query\_partition\_clause and order\_by\_clause.

I wrote the below query:

```
Select customer_id,
       total,
       ROW_NUMBER( ) OVER (PARTITION BY customer_id ORDER BY customer_id ASC) AS "SNO"
from invoice;

```

But the result is failing. What is that I am missing. Also what is meant "the records should be displayed in ascending order based on the customer\_id **and then by SNO**".

The result I am getting is as below:  

CUSTOMER\_ID TOTAL SNO  

1 70000 1  

2 250000 1  

2 560000 2  

**3 200000 1  

3 45000 2**  

4 475000 1  

**5 50000 1  

5 10000 2**  

6 600000 1  

6 90000 2 

Expected result is :  

 CUSTOMER\_ID TOTAL SNO  

1 70000 1  

2 250000 1  

2 560000 2  

**3 45000 1  

3 200000 2**  

4 475000 1  

**5 10000 1  

5 50000 2**  

6 600000 1  

6 90000 2  

 TOTAL Column data is not matching.