Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get count plus detail in single SQL?
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Get count plus detail in single SQL?
Divers
Thread ID:
00663662
Message ID:
00663662
Vues:
38
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform