Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
younas02
Starting Member
28 Posts |
Posted - 2012-06-28 : 10:06:39
|
hi.i want to select rows with count function.i want to select name, fathername, count(marks) with a condition like percentage >50, count(status) with a condition like pass or failis it possible ?plzz help me |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-06-28 : 10:17:45
|
quote: Originally posted by younas02 hi.i want to select rows with count function.i want to select name, fathername, count(marks) with a condition like percentage >50, count(status) with a condition like pass or failis it possible ?plzz help me
Younas,Poste more explaination and some code you have tried to help us help you.luck,--------------------------Get rich or die trying-------------------------- |
 |
|
younas02
Starting Member
28 Posts |
Posted - 2012-06-28 : 10:30:21
|
i have table of student tset results and i have to select name, father name , number of given test, number of pass results , number of fail results. i have these columns and valuesname , fathername , resultyounas, inayat , passali , hammed , failhamad ,nazeer , pass |
 |
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-06-28 : 11:01:52
|
quote: Originally posted by younas02 i have table of student tset results and i have to select name, father name , number of given test, number of pass results , number of fail results. i have these columns and valuesname , fathername , resultyounas, inayat , passali , hammed , failhamad ,nazeer , pass
give an example of of marks (grades) and results you want.What is your question?--------------------------Get rich or die trying-------------------------- |
 |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-28 : 12:45:56
|
It sounds like you want the numbers for a test whereas the data you have given only allows the aggregates by a person taking multiple tests. In fact yoou have no way of not having duplicates (assuming a pearson can pass or fail more than one test).select name, fathername, count(*), sum(case when result = 'pass' then 1 else 0 end), sum(case when result = 'fail' then 1 else 0 end)from tblgroup by name, fathernameHope you pass!==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
younas02
Starting Member
28 Posts |
Posted - 2012-07-02 : 05:11:37
|
thnx alot dear it works for me.thnx thnx |
 |
|
|
|
|
|
|