Answers for "sql group by sum with condition"

SQL
1

sql group by sum with condition

SELECT CityID, 
       COUNT(*) NumberOfDogsInThisCity,
       SUM(CASE WHEN DogName = 'Tedy' THEN Wheight ELSE 0 END) WheightOfAllDogWithNameTedy
FROM Dogs
GROUP BY CityID
Posted by: Guest on July-09-2021
1

sum with group by in sql server

SELECT cust_city, SUM (opening_amt + receive_amt) 
FROM customer 
GROUP BY cust_city;
Posted by: Guest on June-30-2021
1

sql group by sum

// Use SQL Group By clause after the Where clause
// Any column in the select list must either be in the Group By clause 
// or part of an agregation statement, like the Sum() statement
// Multiple columns can be included in the Group By Clause seperated by a comma
// Multiple columns stipulate the order tree. Order by 
// first column, then second ... etc

Select LastName, FirstName, Sum(LeaveDays), Max(age)
From EmployeeProjects
Where StartDate > '2020-01-01'
Group By LastName, FirstName
Posted by: Guest on November-04-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language