i still dont get it… why did SQL returned a long column woth “1” every raw when I gave…
Jump to turn (10)
- 1i still dont get it… why did SQL returned a long column woth “1” every raw when
- 2can you give an exampel?
- 3what will be the difference between SELECT Department, Name, COUNT() FROM Employ
- 4what will be the result of this: GROUP BY Department, Name, SELECT Department, N
- 5i ment this: select COUNT(Name) FROM Employees GROUP BY Department?
- 6sorry, I ment this: name, Department, COUNT(Name) FROM Employees GROUP BY Depart
- 7how about this: SELECT Department, COUNT(Name) FROM Employees GROUP BY Departmen
- 8how about this: SELECT Name, Department, COUNT(Department) FROM Employees GROUP
- 9so I dont understand the difference between this and SELECT Name, Department, CO
- 10is there adiffernce between SELECT Name, Department, COUNT() FROM Employees GROU
- User
i still dont get it… why did SQL returned a long column woth “1” every raw when I gave it this: select count(*) FROM Production.Product group by name
- Assistant
When you use the SQL query "SELECT COUNT(*) FROM Production.Product GROUP BY name", it will group the products by their name and count the number of rows in each group.
However, since you are only selecting the count, the SQL engine has no way of knowing which name corresponds to which count. To maintain the groupings, the SQL engine returns a column of "1" for every row in each group.
So, the result will be a table with two columns:
- The first column will contain the count of rows in each group (i.e., the number of products with the same name).
- The second column will contain a "1" value for each row in each group, which means that all rows in each group have been counted.