Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Help needed with Select and Count
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Help needed with Select and Count

 Post Reply Post Reply
Author
ctscott View Drop Down
Senior Member
Senior Member


Joined: 27 May 2003
Location: United States
Status: Offline
Points: 246
Post Options Post Options   Thanks (0) Thanks(0)   Quote ctscott Quote  Post ReplyReply Direct Link To This Post Topic: Help needed with Select and Count
    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.


Edited by ctscott - 19 July 2007 at 7:49pm
______________________
College Football Trivia
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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)
Back to Top
ctscott View Drop Down
Senior Member
Senior Member


Joined: 27 May 2003
Location: United States
Status: Offline
Points: 246
Post Options Post Options   Thanks (0) Thanks(0)   Quote ctscott Quote  Post ReplyReply Direct Link To This Post Posted: 20 July 2007 at 9:02pm
Thank you Michael for your help.  You saved me a lot of grief. Clap
______________________
College Football Trivia
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.