Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Filter to MAX Value SQL

$
0
0

Hi All,

I have to create a sales report on how many orders are created in a day, and for what value, standard stuff, or so I thought.

My source table, created by my ERP records changes to previously batched orders, and versions the sales orders. So, if I have four copies of a paticular order which was 100, 200, 300 and 400 - What my current SQL script is telling me is that I had one order for 1000.

The version no. does exisit, so I can filter by that and then group the sales lines, but I would only ever like to see the maximum number.

So far, I have grouped the sales order no. and then MAXed the Version, and summed the Amount to get 1,000.

SQL Server 2012


Viewing all articles
Browse latest Browse all 4871


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>