I am writing a sql query to get sales for different stores on a given day. The query is run against ingres/vectorwise. I want to add a column rank where there is the ranking of the store in regard of sales made in comparaison to all the stores.
My select statement is like follows:
SELECT store_number, sum(sales) as sales
FROM stores_sales_indicators
WHERE day = '2019-07-24'
GROUP BY store_number
I tried different things that I am familiar with from sql-server but none of it worked.
I think this is similar to what you're describing (no day included here but you'll get the idea):
See also the fine manual, here's a link to the section on analytic functions: https://docs.actian.com/vector/5.1/index.html#page/SQLLang%2FAnalytical_Functions.htm