Sort by

recency

|

5445 Discussions

|

  • + 0 comments

    with cte as ( select name, concat("(",substring(occupation,1,1),")") as first from occupations order by name ) select concat(name,first) from cte; with cte2 as( select count(occupation)as occupation_cnt, lower(occupation) as loccupation from OCCUPATIONS group by occupation order by occupation_cnt, loccupation ) select concat("There are a total of ", occupation_cnt," ",loccupation,"s.") from cte2;

  • + 0 comments

    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; Oracle

  • + 0 comments

    mysql

    SELECT CONCAT(name, '(', LEFT(occupation, 1), ')') FROM occupations order by name;

    SELECT CONCAT('There are a total of ', count.cnt, ' ', count.occupation, 's.') as str FROM ( SELECT LOWER(occupation) as occupation, COUNT(*) as cnt FROM occupations GROUP BY Occupation ) AS count order by cnt, occupation

  • + 0 comments

    SELECT Name || '(' || LEFT(Occupation, 1) || ')' AS FormattedName FROM OCCUPATIONS ORDER BY Name;

    SELECT 'There are a total of ' || COUNT(Occupation) || ' ' || LOWER(Occupation) || 's.' AS Summary FROM OCCUPATIONS GROUP BY Occupation ORDER BY COUNT(Occupation), Occupation;

  • + 0 comments

    My solution:

    SELECT CONCAT(Name, '(', LEFT(Occupation, 1), ')') AS Output
    FROM OCCUPATIONS
    ORDER BY Name;
    
    SELECT CONCAT('There are a total of ', COUNT(*), ' ', LOWER(Occupation), 's.') AS Output
    FROM OCCUPATIONS
    GROUP BY Occupation
    ORDER BY COUNT(*) ASC, Occupation ASC;