Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MySQL - Select Count help !

    Hi All,

    I was wondering if someone could help me on the following issue im having.

    I have imported a .csv into a mysql table. The contents of the .csv is :


    171767567,(agent_name)
    171767681,(agent_name)
    171770100,(agent_name)
    171770316,(agent_name)


    So so there are 2 x columns, 1 = Account which represents the numeric values, and is a INT type. 2nd column is Agent and represents the agent_name.

    This is where im having trouble, i want to extract how many chats a particular agent has taken in accordance to the account id.

    For example this is the mysql command im running :


    Code:
    select count(*) from csa_totals where Account like "1%" and Agent in ("agent_name");
    Now the Count value returns 0.. which is odd because the data exists or perhaps im doing something wrong...

    So to sum up i need to find how many chats an agent has taken depending on the Account type... ie. 1% i would assume means anything starting with 1..

    Could anyone please advise...?

    Thanks !

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,573
    Thanks
    23
    Thanked 643 Times in 642 Posts
    Use Agent = "agent_name" and see what you get.

  • #3
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Did you look at the table to see if the import worked correctly? if you imported incorrectly all the data could be in a single field for each row.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,084
    Thanks
    80
    Thanked 4,553 Times in 4,517 Posts
    How about:
    Code:
    select LEFT(Account,1) AS accountType, count(*) AS theCount
    FROM csa_totals 
    WHERE Agent = 'joe schmo'
    GROUP BY LEFT(Account,1)
    ORDER BY accountType
    This assumes that the first digit specifies the account type. If it's more complex than that (e.g., "1%" is one account type, "20%" through "24%" is another, "25%" through "29%" is another etc.) let me know.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •