Print Page | Close Window

Help needed with Select and Count

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=23850
Printed Date: 29 March 2026 at 7:40am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Help needed with Select and Count
Posted By: ctscott
Subject: Help needed with Select and Count
Date Posted: 19 July 2007 at 7:46pm
I'm trying to count the number of records by Dept. that meets the select criteria.  I guess this is possible.  So far all I've been able to return is nothing for a count.   the correct records are being selected and displayed on the page.  i just need to put a count by them.
 
my code is
 
strSql = "SELECT tblEmployee_Answers.Emp_Dept, COUNT(*) as 'EXPR1' FROM tblEmployee_Answers"
strSql = strSql & " WHERE (tblEmployee_Answers.Emp_EOS_Date > '" & FromDate & "')"
strSql = strSQL & " AND tblEmployee_Answers.Emp_Opt_Out = '0'"
strSql = strSql & " AND (tblEmployee_Answers.Emp_EOS_Date < '" & ToDate & "')"
strSql = strSql & " AND (tblEmployee_Answers.Emp_Dept IS NOT NULL)"
strSql = strSql & " GROUP BY tblEmployee_Answers.Emp_Dept"
 
am i way off base here?  is this even doable?  help gladly accepted.


-------------
______________________
http://www.cfbtrivia.com" rel="nofollow - College Football Trivia



Replies:
Posted By: michael
Date Posted: 20 July 2007 at 3:00pm
Almost.
This should work. (Just replace variables....

SELECT     Emp_Dept, COUNT(*) AS Expr1, Emp_EOS_date
FROM         tlbEmployee_Answers
WHERE     (Empt_Opt_Out = 0) AND (NOT (Emp_Dept IS NULL))
GROUP BY Emp_Dept, Emp_EOS_date
HAVING      (Emp_EOS_date > @fromdate) AND (Emp_EOS_date < @ToDate)


-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: ctscott
Date Posted: 20 July 2007 at 9:02pm
Thank you Michael for your help.  You saved me a lot of grief. Clap

-------------
______________________
http://www.cfbtrivia.com" rel="nofollow - College Football Trivia



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net