Home > Mobile >  What will be SQL syntax for Show the artists with number of albums they have in descending order
What will be SQL syntax for Show the artists with number of albums they have in descending order

Time:10-17

Two tables Album (AlbumId, Title, ArtistID) and Artist (ArtistId and Name) are given.

SELECT ARTISTID FROM ALBUMS GROUP BY ARTISTID HAVING COUNT(ARTISTID)

CodePudding user response:

Keep in mind that HAVING COUNT is used to:

The MySQL HAVING clause is used in combination with the GROUP BY clause to restrict the groups of returned rows to only those whose the condition is TRUE. Check to learn about HAVING COUNT clause: enter image description here

  • Related