Kaushik Halvadia Kaushik Halvadia - 3 months ago 6
SQL Question

use of sub query in sum aggregate function

The following query

select OrderID,fltprc
from tab1


Gives me following result:

OrderID#      fltprc

1595           101.85

1585           25.00

1585           25.00

1682           200.54

And I want sum of fltprc based on unique id

it means sum of fltprc of unique order.

Answer

Try this:

SELECT SUM(DISTINCT fltprc) FROM tab1
Comments