Appendix B. Solutions to Exercises
This appendix contains answers to the set of exercises at the end of each chapter. Keep in mind that there are often several ways to arrive at the correct answer, so if your answer doesn’t exactly match what is listed, you may have created an equally correct alternate solution.
Chapter 1
Solution to Exercise 1-1
Write a query to retrieve the n_nationkey
and n_name
columns from the Nation
table. Sort the rows by n_name
values.
PUBLIC>select n_nationkey, n_name from nation order by n_name; +-------------+----------------+ | N_NATIONKEY | N_NAME | |-------------+----------------| | 0 | ALGERIA | | 1 | ARGENTINA | | 2 | BRAZIL | | 3 | CANADA | | 18 | CHINA | | 4 | EGYPT | | 5 | ETHIOPIA | | 6 | FRANCE | | 7 | GERMANY | | 8 | INDIA | | 9 | INDONESIA | | 10 | IRAN | | 11 | IRAQ | | 12 | JAPAN | | 13 | JORDAN | | 14 | KENYA | | 15 | MOROCCO | | 16 | MOZAMBIQUE | | 17 | PERU | | 19 | ROMANIA | | 22 | RUSSIA | | 20 | SAUDI ARABIA | | 23 | UNITED KINGDOM | | 24 | UNITED STATES | | 21 | VIETNAM | +-------------+----------------+ ...
Get Learning Snowflake SQL and Scripting now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.