![]() OrderNumber = 10100 Code language: SQL (Structured Query Language) ( sql ) The following shows the order line items of the order number 10110: SELECT Orderdetails Code language: SQL (Structured Query Language) ( sql ) 2) MySQL SUM() function with expression example This example uses the SUM() function to get the total number of items of the order details: SELECT SUM(quantityOrdered) SalesQuantity ![]() Let’s take a look at the table orderdetails in the sample database. In this case, the SUM() with the DISTINCT option only calculates the sum of distinct values which are 1, 2 and 3. ![]() And it ignores NULL.įinally, use the SUM() with the DISTINCT option to calculate the total values in the n column: SELECT SUM( DISTINCT n) Sum_demo Code language: SQL (Structured Query Language) ( sql )Īs you can see, the SUM() function calculates the total of 1, 1, 2, and 3. Third, use the SUM() function to calculate the total values in the n column: SELECT SUM(n) Then, insert some rows into the sum_demo table: INSERT INTO sum_demo(n)Ĭode language: SQL (Structured Query Language) ( sql ) ) Code language: SQL (Structured Query Language) ( sql )
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |