Skip to content
Advertisement

SQL subtracting 2 subqueries

Fairly new to SQL and I wanted to see if I could get some help with subtraction. I want to subtract studentstaken – studentsnotreviewed and then as assign the alias total to the operation. I was thinking something along the lines of

But getting some syntax problems I’m not too sure about.

[Sample data]

School Name examstart examend studentstaken studentsnotreviewed IDtoggle Roomscanetoggel
University of Texas Health Sciences Houston EXAM 1 Feb 3, 2021, 10:55 AM Feb 3, 2021, 1:30 PM 26 2 1 1
University of Texas Health Sciences Houston EXAM 1 Feb 4, 2021, 10:45 AM Feb 4, 2021, 12:59 PM, 12:59 AM 31 1 1 1

[Desired result]

School Name examstart examend studentstaken studentsnotreviewed total IDtoggle Roomscanetoggel
University of Texas Health Sciences Houston EXAM 1 Feb 3, 2021, 10:55 AM Feb 3, 2021, 1:30 PM 26 2 24 1 1
University of Texas Health Sciences Houston EXAM 1 Feb 4, 2021, 10:45 AM Feb 4, 2021, 12:59 PM, 12:59 AM 31 1 30 1 1

Advertisement

Answer

It should be ok.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement