Hi,I have the following query, which is working perfectly, but I would like to add some extended functionality on to it.In addition to the "totalPics" column, I want to add a "totalPics1" and "totalPics2". TotalPics will be the sum of these two columns. Each column will represent the associated genderID of the photo.I can access "tblUserDetails.genderID" in the following manner.JOIN tblExtraPhotos EP on EP.counterID = FP.counterIDJOIN tblUserDetails UD2 on UD2.userID = EP.userIDHere is the original query SELECT TOP 40 FP.userID, count(*) AS totalPics, max(dateAdded) AS m_dateadded, UD.nameOnlineFROM tblfavouritephotos FPJOIN tblUserDetails UD on UD.userID = FP.userIDGROUP BY FP.userID, nameOnlineORDER BY m_dateadded desc
Here is it modified to add the JOIN's that I think it needs. It runs fine, but I'm not sure how to select the totalPics1 and totalPics2 columns.pseudocode:totalPics1 = count(*) WHERE genderID=1totalPics2 = count(*) WHERE genderID=2SELECT TOP 40 FP.userID, count(*) AS totalPics, max(dateAdded) AS m_dateadded, UD.nameOnline FROM tblfavouritephotos FPJOIN tblUserDetails UD on UD.userID = FP.userIDJOIN tblExtraPhotos EP on EP.counterID = FP.counterIDJOIN tblUserDetails UD2 on UD2.userID = EP.userIDGROUP BY FP.userID, UD.nameOnlineORDER BY m_dateadded desc
Does this make sense? Any help is much appreciated..Thanks again!mike123