| Author |
Topic |
|
phoenix23
Starting Member
6 Posts |
Posted - 2010-07-14 : 04:30:24
|
| hi everyone, right now i am doing an assignment in asp.net.my current table MemberManagement is like this MemberManagementstrFullName.......strEmail............blnIsPostedAmresh............amresh@hotmail.com......0Amresh............amresh@hotmail.com......1Amresh............amresh@hotmail.com......1Izzat.............izzat@hotmail.com.......1Izzat.............izzat@hotmail.com.......1But right now, I need to get thisMemberManagementstrFullName.......strEmail................blnIsPostedAmresh..........Amresh@hotmail.com...........2Izzat...........Izzat@hotmail.com............2basically the blnIsPosted is to count the number of dvd titles which is posted to the member |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-07-14 : 04:34:23
|
| Select strFullName, strEmail, sum(blnIsPosted) from table_namegroup by strFullName, strEmailSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2010-07-14 : 04:36:42
|
quote: Originally posted by phoenix23 hi everyone, right now i am doing an assignment in asp.net.my current table MemberManagement is like this MemberManagementstrFullName.......strEmail............blnIsPostedAmresh............amresh@hotmail.com......0Amresh............amresh@hotmail.com......1Amresh............amresh@hotmail.com......1Izzat.............izzat@hotmail.com.......1Izzat.............izzat@hotmail.com.......1But right now, I need to get thisMemberManagementstrFullName.......strEmail................blnIsPostedAmresh..........Amresh@hotmail.com...........2Izzat...........Izzat@hotmail.com............2basically the blnIsPosted is to count the number of dvd titles which is posted to the member
do u want the count or sum of the blnisposted.... ur showing the sum in the required output. |
 |
|
|
phoenix23
Starting Member
6 Posts |
Posted - 2010-07-14 : 04:41:15
|
hi... sorry its actually the sum of all "true" blnIsPostedso lets say its likestrFullName.......strEmail............blnIsPostedAmresh............amresh@hotmail.com......0Amresh............amresh@hotmail.com......1Amresh............amresh@hotmail.com......1Amresh............amresh@hotmail.com......1Izzat.............izzat@hotmail.com.......1Izzat.............izzat@hotmail.com.......1MemberManagementstrFullName.......strEmail................blnIsPostedAmresh..........Amresh@hotmail.com...........3Izzat...........Izzat@hotmail.com............2blnIsPosted is a boolean variable.. i dont know why, my teacher set it as such thanks for your help guys |
 |
|
|
phoenix23
Starting Member
6 Posts |
Posted - 2010-07-14 : 04:50:56
|
| YAY i got it :D !!!I used senthil_nagore code and modify it a little from browsing the net... basically the code i got look kinda like thisSelect strFullNameUs, strEmailus, sum(case when blnIsPostedMO = 1 then 1 else 0 end) from membermanagementgroup by strFullNameus, strEmailusthanks alot guys!! :D |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-07-14 : 04:56:21
|
quote: Originally posted by phoenix23 YAY i got it :D !!!I used senthil_nagore code and modify it a little from browsing the net... basically the code i got look kinda like thisSelect strFullNameUs, strEmailus, sum(case when blnIsPostedMO = 1 then 1 else 0 end) from membermanagementgroup by strFullNameus, strEmailusthanks alot guys!! :D
No need to modify..If we add with "0" that doesn't change the value.Still u want to change use Where clauseSelect strFullNameUs, strEmailus, sum(blnIsPostedMO) from membermanagement where blnIsPostedMO=1group by strFullNameus, strEmailusSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
phoenix23
Starting Member
6 Posts |
Posted - 2010-07-14 : 10:48:18
|
| cheers matebut there's one probwhen i put it on asp.net,it returnsstrFullName.......strEmail................blnIsPostedAmresh..........Amresh@hotmail.com...........TrueIzzat...........Izzat@hotmail.com............TrueBut on sql it returns whats i want which isstrFullName.......strEmail................blnIsPostedAmresh..........Amresh@hotmail.com...........3Izzat...........Izzat@hotmail.com............2 |
 |
|
|
KrafDinner
Starting Member
34 Posts |
Posted - 2010-07-14 : 10:53:11
|
| Is the ASP field that is displaying coded as a boolean ? If so, you'll need to change the type of that to int...If I remember correctly, it treats any non-zero as true. |
 |
|
|
|