Skip to content
Advertisement

How to list 3 largest numbers from table in SQL?

I’m trying to unite two bits of SQL codes and list three largest numbers from it. Here is table relation diagram

Query #1:

Query #2:

My final code shows the full list of all first and second names, simply adding largest number to all of them from orders table. How can I modify it to make it show three names with its largest delivery count?

Advertisement

Answer

If you want exactly the top 3 (or less if there are less than 3) then use order by the attribute you want, and use limit:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement