Back to articles
DB-TASK-001

DB-TASK-001

via Dev.to BeginnersSandhya Steffy M

Retrieving Data with Column Aliases Sometimes, column names in tables are not user-friendly. So, we can rename them using aliases. SELECT title AS "Movie Title", rental_rate AS "Rate" FROM film; Displaying Customer Details We can also rename customer details to make them clear. SELECT first_name AS "First Name", last_name AS "Last Name", email FROM customer; Sorting Data (ORDER BY) Sorting helps us organize data. SELECT title, rental_rate FROM film ORDER BY rental_rate DESC, title ASC; Sorting Actor Names SELECT first_name, last_name FROM actor ORDER BY last_name, first_name; This sorts actors by last name first. Using DISTINCT (Unique Values) To avoid duplicates, we use DISTINCT. SELECT DISTINCT replacement_cost FROM film; This shows only unique values. Showing Film Duration SELECT title, length AS "Duration (min)" FROM film; Here, length is renamed to make it clearer. Customer Active Status SELECT first_name, last_name, active AS "Is Active" FROM customer; This shows whether a custom

Continue reading on Dev.to Beginners

Opens in a new tab

Read Full Article
7 views

Related Articles