I am just starting SQL and am using version SQL server 2016(few days in to learning)
I am using the WideWorldImporters DB from microsoft.
The basics of my question is I don't understand some results I am getting and why? I run this command: use WideWorldImporters select top (2) OrderID From Sales.Orders;
and it returns a table with 2 lines as expected but the OrerID column values for the two rows of 1 and 16
However when I run the command: select top (2) OrderID, CustomerID From Sales.Orders;
I get the additional column for customerID with 1 and 1, and for the ORDERID column it now returns row values of 2934 and 3482.
I don't understand why OrderID would return the two different results. Am I running the command incorrectly?
I am trying to learn the sum and avg aggregate commands on just the top X rows of the column OrderID with the GROUP BY CUSTOMERID for testing, but ultimately want to do below
This is what I was trying to imagine doing: If you imagined that OrderID was in fact an total order price, I was trying to sum up each customers order total from all purchases. So sum up every row with customerid = N and then list all the totals for every customerid. My select top 2 was for testing purposes so it wasn't final results, but led me to discrepancy.