I am learning BigQuery in Coursera. I am trying to sort a table but I am confused about how to use ORDER BY.
My table has columns like name and age. I want to sort the age from highest to lowest. What is the correct SQL query to do this?
Simply use it like this:
SELECT name, age
FROM your_table
ORDER BY age DESC;
The syntax is to first do ORDER BY, then mention the column. Finally, if you want descending order, use DESC. Ascending is default.
name, better separate columns for first name and last name. 3) Do not use a columnagebecause you need to update it quite often or the age will be incorrect. Avoid this trouble and rather use a columndate_of_birth.