Skip to content

Latest commit

 

History

History
40 lines (23 loc) · 1.22 KB

File metadata and controls

40 lines (23 loc) · 1.22 KB

SQL language

SQL language code here.

Example of Left, Right, Full Outer Join statements

SELECT a.*, b.*

    FROM sec1413_fruits a
    
    LEFT OUTER JOIN sec1413_colors b -- Left outer join statement collects data from 'sec1413_colors b' of rows to the right side column so that it matches with the data on the left side of the table.
    
    ON a.f_num = b.c_num
    
    UNION

SELECT a.*, b.*

    FROM sec1413_fruits a

    RIGHT OUTER JOIN sec1413_colors b -- Right outer join statement collects data from 'sec1413_colors b' of rows to the left side column so that it matches with the data on the right side of the table.
    
    ON a.f_num = b.c_num;

image

Example of using a Substring (SUBSTR) to concatenate names

SELECT employee_id,

    last_name || ' ' || SUBSTR(first_name, 1, 1) AS full_name -- NOTE: SUBSTR can extract strings from a variable string (such as a person, place or thing).
    -- (1 - starting position, 1 - means the length of the character)
    
FROM l_employees;

image