sql - How to use group by without using an aggregation function -


i trying find row number of price while grouping them respect productid. productid = 1, rank of price (where price = 1000) should smt. productid=3, rank of price (= 1000) should sth.

  • how can find row number of price different productid in same table?

  • how can achieve using group without aggregation row_number.

    productid   price -----------------    1         2000    1         1600    1         1000    2         2200    2         1000    2         3250    3         1000    3         2500    3         1750 

so result should be

productid   price   pricerank ------------------------------     1       1000       3     2       1000       2     3       1000       1 

this code:

select      productid,     row_number() on (order price asc) pricerank      product      price = 1000 group      productid 

this give correct result:

select *  (select productid,price,row_number() on (partition productid order productid ) pricerank products) price =1000 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -