Count /Group By

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ArcticCircuits
    New Member
    • Feb 2010
    • 1

    Count /Group By

    Greetings,
    As part of my Highschool project I had to come up with a themed database with a bunch of tables to query from, so I came up with a 'police' database. I am trying to get a count of all data thats in my tblTrafficCodes .Description column and have them grouped so it would look like this:

    Count Description
    3 Tickets
    2 DUI
    3 Fights ... and so on and so on.

    The issue I'm running into is that I get this instead:
    Count Description
    1 Tickets
    1 Tickets
    1 Tickets
    1 DUI
    1 DUI..... and so on.

    I complicated this a bit by having a 5 table join and not sure if thats also contributing to my issue.

    I'm learning both SQL and how to do queries via the Design view. Can't quite figure out how to do this in both

    Can anyone help me please!
  • yarbrough40
    Contributor
    • Jun 2009
    • 320

    #2
    please show me what sql code you have tried so far. Also I would need to see a sample of the table you are attempting to query. depending, you should be using something like:
    Code:
    SELECT Description, COUNT(Description) as Total
    FROM tblTrafficCodes 
    GROUP BY Description
    Last edited by NeoPa; Feb 21 '10, 05:14 PM. Reason: Please use the [CODE] tags provided

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32661

      #3
      You can see the same query (QueryDef) in either SQL view OR Design view.

      I concur with Yarborough in that seeing your SQL would help us to help you more specifically, though what he's already posted may well be enough to set you on the right track.

      Comment

      Working...