@@ -418,7 +418,10 @@ copies_sold
418
418
<details ><summary >Solution</summary >
419
419
420
420
``` sql
421
- SELECT * FROM books ORDER BY copies_sold DESC LIMIT 5 ;
421
+ SELECT *
422
+ FROM books
423
+ ORDER BY copies_sold DESC
424
+ LIMIT 5 ;
422
425
```
423
426
424
427
</details >
@@ -443,7 +446,8 @@ country
443
446
<details ><summary >Solution</summary >
444
447
445
448
``` sql
446
- SELECT * FROM travelers
449
+ SELECT *
450
+ FROM travelers
447
451
WHERE country NOT IN (' Canada' , ' Mexico' , ' USA' );
448
452
```
449
453
@@ -548,7 +552,9 @@ tuition_received (boolean)
548
552
<details ><summary >Solution</summary >
549
553
550
554
``` sql
551
- SELECT * FROM students WHERE tuition_received IS false;
555
+ SELECT *
556
+ FROM students
557
+ WHERE tuition_received IS false;
552
558
```
553
559
554
560
</details >
@@ -677,7 +683,37 @@ employees
677
683
<details ><summary >Solution</summary >
678
684
679
685
``` sql
680
- SELECT * FROM companies ORDER BY employees DESC ;
686
+ SELECT *
687
+ FROM companies
688
+ ORDER BY employees DESC ;
689
+ ```
690
+
691
+ </details >
692
+
693
+ ---
694
+
695
+ ** [ ⬆ Back to Top] ( #sql-coding-challenges-for-beginners ) **
696
+
697
+ ## Counting and Grouping
698
+
699
+ Given a demographics table, your task is to return a table that shows a count of each race represented in descending order.
700
+
701
+ ```
702
+ demographics
703
+ ------------
704
+ id
705
+ name
706
+ birthday
707
+ race
708
+ ```
709
+
710
+ <details ><summary >Solution</summary >
711
+
712
+ ``` sql
713
+ SELECT race, COUNT (* ) AS count
714
+ FROM demographics
715
+ GROUP BY race
716
+ ORDER BY count DESC ;
681
717
```
682
718
683
719
</details >
0 commit comments