+ 1

MySQL subquerie not working out

I am new to MySQL, so be nice 🙂 The code is about students, assignments, due dates, etc I have to write a query plus subquery, that shows the name, latest due date and how many days it is late. So far so good... create table grades ( lname varchar(20) not null, fname varchar (20) not null, due_date date, submit_date date, unit_num int not null, assgn_type char(1) not null, assgn_num int not null, grade int not null ); select concat(fname,' ', lname) as name, due_date, (submit_date - due_date) as days_latefrom grades where due_date in (select max(due_date) from grades) order by days_late desc; ..it is working, but I have to get only 2 positive values. With my code above I get 2 positive and 2 negative numbers (days_late). I have tried: where submit_date - due_date >= 1, but I am not quite sure if and where I could use it.

7th May 2020, 12:34 AM
Stef
Stef - avatar
1 Resposta
0
You are in the right track. Add "and submit_date > due_date" to your where clause.
9th May 2020, 10:44 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar