Home  >  Q&A  >  body text

Select the difference between the maximum and minimum weight of a person with the last name Maroni.

SELECT weight AS weight_delta
from (select max(weight) 
      from patients 
      where last_name='Maroni')
      -
      (select min(weight) 
      from patients 
      where last_name='Maroni');

P粉564301782P粉564301782205 days ago365

reply all(1)I'll reply

  • P粉639667504

    P粉6396675042024-03-29 00:53:00

    You are thinking too complicatedly. Find the difference without any subquery:

    SELECT MAX(weight) - MIN(weight) AS weight_delta 
    FROM patients WHERE last_name = 'Maroni';

    reply
    0
  • Cancelreply