Try It SQL COUNT(DISTINCT expression) example HAVING COUNT(*) > 5 ORDER BY COUNT(*) DESC Code language: SQL (Structured Query Language) ( sql ) Also, it uses a HAVING clause to select only departments that have more than five employees: SELECT The following example returns the number of employees by department. Try It SQL COUNT with HAVING clause example ORDER BY COUNT(*) DESC Code language: SQL (Structured Query Language) ( sql ) INNER JOIN departments d ON d.department_id = e.department_id The following example uses the ORDER BY clause to sort the number of employees by department: SELECT Try It SQL COUNT(*) with ORDER BY clause example Also, it uses an INNER JOIN clause to include the department name in the result set: SELECTĭepartment_name Code language: SQL (Structured Query Language) ( sql ) The following example uses the COUNT(*) function to get the number of employees by department.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |