Link to home
Start Free TrialLog in
Avatar of ramesh_axl
ramesh_axl

asked on

SQL query inlvolving "atleast"

Hi,
     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.




Thanks,
Axl






ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ramesh_axl
ramesh_axl

ASKER

Hi Patrik,

          Thanks for your  reply. I am trying to write a query which is generic i.e i will be knowing the number of subjects at run time.
Hi Patrick,
           I am able to work with the solution you have given.

Thanks a lot