We help IT Professionals succeed at work.
Get Started

COUNT the same column twice

Rouchie
Rouchie asked
on
305 Views
Last Modified: 2012-08-13
I am using the following statement to count the number of "archived" users in my system.  Currently this is showing the number of users not archived, however, I need to expand this to show both the number of archived and non-archived users (u.archived = 1 and also u.archived = 0)

Can anyone please show me how to do this?

SELECT
      COUNT(u.archived),
      si.siteName,
      ol.orgLevelName
FROM
      [tbl_Users] u INNER JOIN
      [tbl_Sites-OrgLevels] sol ON u.siteOrgLevelID = sol.ID INNER JOIN
      [tbl_Sites] si ON si.ID = sol.siteID INNER JOIN
      [tbl_Organisational_Level] ol ON ol.orgLevelID = sol.orgLevelID
WHERE
      (u.customerID = 2) AND
      (u.archived = 0)
GROUP BY
      sol.siteID, si.siteName, sol.orgLevelID, ol.orgLevelName
Comment
Watch Question
Database Engineer
CERTIFIED EXPERT
Top Expert 2005
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE