Advanced Select

Type of Triangle

select 
    case 
        when A >= (B + C) or B >= (A + C) or C >= (A + B) then 'Not A Triangle'
        when A <> B and B <> C and A <> C then 'Scalene'
        when A = B and B = C and A = C then 'Equilateral'
        when A = B or B = C or A = C then 'Isosceles'
    end
from TRIANGLES;

The PADS

select Name || '(' || substr(Occupation,1,1) || ')'  
from OCCUPATIONS
order by Name;

select 'There are a total of ' || count(Occupation) || ' ' || lower(Occupation) || 's.' 
from OCCUPATIONS
group by Occupation
order by count(Occupation), Occupation;

Occupations

// Some code

Binary Tree Nodes

select N,
    case 
        when P is null then 'Root'
        when N in (select P from BST) then 'Inner'
        else 'Leaf'
    end 
from BST
order by N;

New Companies

select 
    C.company_code, C.founder, 
    count(distinct E.lead_manager_code), 
    count(distinct E.senior_manager_code), 
    count(distinct E.manager_code),
    count(distinct E.employee_code)
from company C, employee E
where C.company_code = E.company_code
group by C.company_code, C.founder
order by 1;

Last updated

Was this helpful?