SQL query inlvolving "atleast"
Posted on 2007-07-24
I have a question regarding SQL Query. For ex:- consider the following schema.
studentID name sub1 sub2 sub3 sub4 sub5
1001 abc 67 34 56 78 89
1002 xyz 67 65 23 76 45
sub1,sub2,sub3... fields contain the marks in that particular subjects.
Query :- Find the names of the students who got 50 in atleast 3 subjects.
to make this query generic, let
m - be the number of subjects(for the above query it is "5")
n - is the atleast count(for the above query it is "3")
I am having a touch time to write a query which is generic i.e m , n can be any value.Any help would be greatly appreciated.
Database : SQL Server 2000
It would be great if the query is not specific to any Database vendor i.e if it is according to standards.