Lowe’s Interview Questions | Over-weight

Question

Suppose in class, you have 3n boys and 2n girls with their names tabulated along with their weight and gender. Write a SQL query to separate students alphabetically who are over-weight (55kg for girls, 75kg for boys)

in progress 0
Dhruv2301 55 years 11 Answers 1711 views Great Grand Master 2

Answers ( 11 )

  1. select name,gender if(gender=’M’, weight>’75kgs’,weight>’55kgs’) as weights from table_name;

  2. select *
    from table_name
    where gender = ‘Male’ and weight > ’75kg’
    union all
    select *
    from table_name
    where gender = ‘Female’ and weight > ’55kg’

  3. select * from table_name where gender=’M’ and weight >75 or gender=’F’ and weight >55;

  4. select * from table_name where (gender=’male’ and weight>75) or (gender=’female’ and weight>55) order by name;

  5. SELECT * FROM students
    WHERE (gender = ‘M’ AND weight > 75) OR(gender = ‘F’AND weight > 55)
    ORDER BY name

  6. select * FROM students where (gender = ‘M’ and weight > 75) or (gender = ‘F’AND weight > 55) order by name;

  7. select * from table_name where (gender=’male’ and weight>75) or (gender=’female’ and weight>55) order by name;

  8. Select name,gender from
    (select name,gender ,if(gender=’m’,weight >’75’,weight>’55’) as weights
    from names
    having weights =1
    order by name) as s;

  9. select name, gender, weight
    from table
    where
    (gender=’male’ and weight>= 75)
    or
    (gender =’female’ and weight >= 55)
    order by name asc

  10. SELECT *
    FROM table
    WHERE (lower(gender)=’female’ and Cast (weight AS INT) >55)
    OR (lower(gender)=’male’ and Cast(weight AS INT) > 75)
    ORDER BY name;

  11. SELECT *
    FROM table_name
    WHERE (lower(gender)=’female’ and Cast (weight AS INT) >55)
    OR (lower(gender)=’male’ and Cast(weight AS INT) > 75)
    ORDER BY name;

Leave an answer

Browse
Browse