Avatar of kdeutsch
kdeutschFlag for United States of America

asked on 

Count multiple fields in SQL

I have a table full of people wihch is an attendance database.  What I have to do is count the number of people each day and then sub count the types of Rnak that they are.  So the iniatial count of people but date is no problem.  the problem comes in that I have to count them by rank as well which is in another Personnel table.  This is what I have so far.  So I only have the SSN in teh tblAssignedPersonnel which is the attendance table.  So I count the SSN's per date of attendance, now I need to sub count how many are Enllisted, officers.  So I need to take those same people and query there grade an then count them intothe specific groups.

Select      Count(p.strssn)as Total,
                     Case when COunt(s.strGrade) in ('E1', 'E2', 'E3') as Enlisted
                     Case when COunt)s.strGrade) in ('O1',  'O2', 'O3') as Officer
from      tblAssignedPersonnel as p INNER JOIN
      MnAIrPersonnel as s on s.strSSN = p.strSSN
Where      bitpresent = 1 and dtAttendance = '7/23/2008'
      and IntUIcId In (Select intUicId from tblUIC where inttaskforceID = 1 and strUic = 'F41CFMBM')
Microsoft SQL Server 2005SQL

Avatar of undefined
Last Comment
kdeutsch
ASKER CERTIFIED SOLUTION
Avatar of chapmandew
chapmandew
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of kdeutsch
kdeutsch
Flag of United States of America image

ASKER

chapmandew,
AHHHHHHHH,
Got it  Works great.
Avatar of kdeutsch
kdeutsch
Flag of United States of America image

ASKER

Sorry,
Thank You as well
Microsoft SQL Server 2005
Microsoft SQL Server 2005

Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.

72K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo