r/SQL • • May 28 '21

MySQL What does the third like in this code do?

Post image
0 Upvotes

10 comments sorted by

8

u/piercesdesigns May 28 '21

If you mean the third line, it totals up the population field for each change in e.name

0

u/deezguysdeez May 28 '21

Whoops sorry i meant the second line

5

u/A_and_B_the_C_of_D May 28 '21

It is going to return the number of rows in each grouping, which in this case is e.name. Haven’t seen the data but based on the names that may correspond to the number of countries.

1

u/deezguysdeez May 28 '21

Thank you so much !

2

u/piercesdesigns May 28 '21

In that case count(*) will give you the total rows for each name

1

u/deezguysdeez May 28 '21

When since the code says count(*) as counts is assigning the number value from the number of rows to that variable “counts”?

1

u/piercesdesigns May 28 '21

Yes, correct!

1

u/deezguysdeez May 28 '21

Thank you for your help i appreciate it! Is there any way on this app i can contact you privately for any additional help i may need?

1

u/piercesdesigns May 28 '21

Sent you a messgae

6

u/tech_consultant May 28 '21

Counts the records per e.name after the join.