Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get count plus detail in single SQL?
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Get count plus detail in single SQL?
Miscellaneous
Thread ID:
00663662
Message ID:
00663662
Views:
39
I'm doing a survey module and want to run a single query that gives me the total number of votes in a survey (easy with COUNT and GROUP BY), PLUS whether the logged in user voted in each one or not.

One table is Questions, the second is Votes. Here's what I have - it gives the vote count for each question, but not whether the current user (lcUserCode) voted in each one:
SELECT Questions.*, UserCode, COUNT(UserCode) AS VoteCount ;
	FROM Questions ;
	LEFT JOIN Votes ;
	WHERE Questions.SurveyPK=Votes.SurveyPK ;
	ORDER BY CloseDate DESC ;
	GROUP BY SurveyPK ;
	INTO CURSOR TQuery
SurveyPK is the PK in the Questions table. Of course, I'm interested in listing all questions.

Any ideas?
Kogo Michael Hogan

"Pinky, are you pondering what I'm pondering?"
I think so Brain, but "Snowball for Windows"?

Ideate Web Site
Next
Reply
Map
View

Click here to load this message in the networking platform