--PRACTICE PART: --OLYMPICS DATABASE --1.Return the ID and the number of medals of each country -- which gained exactly the same number of gold, silver and bronze medals. --2.Return the ID and the number of medals of each country which number of gold medals is between 5 and 9. --3.Return each country which name ends with 'istan'. --4.Return each country which name starts with 'A' and at least 8 letters long. --5.Return each country which area starts with '3'. --6.Return the ID and the number of medals of each country. -- Sort the countries by the number of gold medals in descending order. --7.Return all the data of each event which name is missing. --------------------------------------------------------------- --DATE FUNCTIONS----------------------------------------------- --------------------------------------------------------------- --TO_DATE() --TO_CHAR() --EXTRACT() --MONTHS_BETWEEN() --ADD_MONTHS() --NEXT_DAY() --LAST_DAY() --------------------------------------------------------------- --DISTINCT --------------------------------------------------------------- --ALIASES --------------------------------------------------------------- --NVL() -- The NVL() function allows you to replace null -- with a more meaningful alternative in the results of a query. --1. Return the name, the population and the continent of country Cook Islands. --2. Return the name, the population and the continent of country Cook Islands. --Replace the missing continent name with string 'unknown'. --------------------------------------------------------------- --LOWER(), UPPER(), INITCAP() -- lower() - Convert the text to lower-case -- upper() - Convert the text to upper-case --------------------------------------------------------------- --SUBSTR() --syntax: --substr(column_name, start_position, number_of_char.) --------------------------------------------------------------- --REPLACE() -- The REPLACE() function replaces all occurrences -- of a substring within a string, with a new substring. -- Syntax: -- REPLACE(string, old_string, new_string) --------------------------------------------------------------- --INSTR() --syntax: instr(string, substring) --------------------------------------------------------------- -- GROUP BY -- The SQL GROUP BY Statement -- The GROUP BY statement groups rows that have the same values into -- summary rows, like "find the number of customers in each country". -- The GROUP BY statement is often used with -- aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group -- the result-set by one or more columns. -- GROUP BY Syntax -- SELECT column_name(s) -- FROM table_name -- [WHERE condition] -- [GROUP BY column_name(s)] -- [ORDER BY column_name(s)]; --------------------------------------------------------------- -- HAVING -- The SQL HAVING Clause -- The HAVING clause was added to SQL because the WHERE keyword -- cannot be used with aggregate --functions. -- HAVING Syntax -- SELECT column_name(s) -- FROM table_name -- [WHERE condition] -- [GROUP BY column_name(s)] -- [HAVING condition] -- [ORDER BY column_name(s)]; ---------------------------------------------------------------