Get a great number of members
I may be stupid here, but consider this table
I want the number of unique members to be logged, so I use this query
$sql="SELECT DISTINCT member_nr, count(member_nr) as nr FROM Multiple_Orders
Where order = '$pTour' AND round ='$pRound'";
My problem
This returns 6
Of course there are 6 members in the column, but I want to get the number of unique members that should be 2 , so I useDistinct
What am I missing here
+3
source to share
2 answers
this is how you use DISTINCT
$sql="SELECT DISTINCT(member_nr) as nr FROM Multiple_Orders
Where order = '$pTour' AND round ='$pRound'";
which will give you a list of unique members
and this is how you count how many unique members you have
$sql="SELECT COUNT(DISTINCT(member_nr)) as nr FROM Multiple_Orders
Where order = '$pTour' AND round ='$pRound'";
which will give you the number of unique members
+4
source to share
Use query to get the number of different members:
$sql="SELECT count(distinct(member_nr)) as nr FROM Multiple_Orders
Where order = '$pTour' AND round ='$pRound' group by member_nr";
Use query to get individual member:
$sql="SELECT distinct(member_nr) as nr FROM Multiple_Orders
Where order = '$pTour' AND round ='$pRound' group by member_nr";
Add a software group to get unique members and count each member:
$sql="SELECT member_nr, count(member_nr) as nr FROM Multiple_Orders
Where order = '$pTour' AND round ='$pRound' group by member_nr";
+2
source to share