troubleshooting Question

SQL query inlvolving "atleast"

Avatar of ramesh_axl
ramesh_axl asked on
DatabasesOracle DatabaseMicrosoft SQL Server 2005
3 Comments1 Solution294 ViewsLast Modified:
     I have a question regarding SQL Query. For ex:- consider the following schema.

Student table:

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.


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros