theorem_hunter
May 4th, 2007, 09:10 PM
i just need something cleared up here...
i am studying for a discrete maths test, inclusion-exclusion principles is on of the topics being covered, and i was wondering if that is the same principle for SQL statements.
inclusion-exclusion - here is 1 part of a question:
In a class of 200 students 75 take maths, 70 take stats & 75 take zoology.
35 take maths & zoology
20 take stats & zoology
40 take maths & stats
15 take all 3 subjects
so this becomes...
|U| = 200
|M| = 75
|S| = 70
|Z| = 75
|M∩Z| = 35
|S∩Z| = 20
|M∩S| = 40
|M∩S∩Z| = 15
Q. How many take at least 1 of the 3 subjects?
A.
|M∪S∪Z| = |M| + |S| + |Z| - |M∩S| - |M∩Z| - |S∩Z| + |M∩S∩Z|
= 75 + 70 + 75 - 40 - 35 - 20 + 15
= 140
140 students take at least 1 of the 3 subjects
sql - this is not a working sql statement... im just trying to show/understand the concept.
my question...
could a sql statement for the above maths statement look like this? or what would the sql statement look like?
select *
from U
where ((M + S + Z) - ((M+S)-(M+Z)-(S+Z)) + (M+S+Z) <= U)
do sql select-from-where statements use inclusion exclusion principles to get their answers? thanks
i am studying for a discrete maths test, inclusion-exclusion principles is on of the topics being covered, and i was wondering if that is the same principle for SQL statements.
inclusion-exclusion - here is 1 part of a question:
In a class of 200 students 75 take maths, 70 take stats & 75 take zoology.
35 take maths & zoology
20 take stats & zoology
40 take maths & stats
15 take all 3 subjects
so this becomes...
|U| = 200
|M| = 75
|S| = 70
|Z| = 75
|M∩Z| = 35
|S∩Z| = 20
|M∩S| = 40
|M∩S∩Z| = 15
Q. How many take at least 1 of the 3 subjects?
A.
|M∪S∪Z| = |M| + |S| + |Z| - |M∩S| - |M∩Z| - |S∩Z| + |M∩S∩Z|
= 75 + 70 + 75 - 40 - 35 - 20 + 15
= 140
140 students take at least 1 of the 3 subjects
sql - this is not a working sql statement... im just trying to show/understand the concept.
my question...
could a sql statement for the above maths statement look like this? or what would the sql statement look like?
select *
from U
where ((M + S + Z) - ((M+S)-(M+Z)-(S+Z)) + (M+S+Z) <= U)
do sql select-from-where statements use inclusion exclusion principles to get their answers? thanks