Group By SQL Server Function [closed]

0

I'm new to SQL Server , I'd like some help to understand the Group By function in a simple way. Both its concept and how to use ... for anyone who can help me thank you right away!

    
asked by anonymous 12.12.2018 / 18:54

1 answer

3

There are some functions like COUNT, MAX, MIN, SUM and AVG, in which they group some results, let's suppose you do:

select COUNT(nome) from pessoa

This will group all the names in a result, then generate the account names, let's assume that we have 4 names, the result of the sum would be 4.

But suppose you wanted to account for the same names, so you would

select COUNT(nome) from pessoa group by nome

So he will group all the names together and show the quantity, so let's suppose that of these 4 there are 2 identical names john and the other two different, so the result would be 2 because of the two john and then we would have two more results 1 and 1 referring to the different names that are left over.

See some examples

Example 1 Example 2 Example 3

Font

    
12.12.2018 / 19:00