Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2011
    Posts
    7

    Unanswered: Query to display this output

    Table Name--CustomerInfo
    HTML Code:
    PhoneNo.                   AgentName             Status
    ------------------------------------------------------
    8086817429                 Agent1                  RPC
    8129001663                 Agent2                  NCT
    8129008620                 Agent3                  NCT
    8129011825                 Agent4                  RPC
    8129012154                 Agent2                  BUS
    8129016296                 Agent4                  RPC
    8129016581                 Agent3                  BUS
    8129024743                 Agent2                  NCT
    8129032230                 Agent1                  NCT
    8129033135                 Agent4                  BUS
    8129043752                 Agent1                  RPC
    8129078552                 Agent3                  RPC
    8129567852                 Agent1                  BUS 
    8129874122                 Agent2                  BUS
    8129056982                 Agent4                  BUS

    I need to know the query to display distinct AgentName in one column and count of their RPC status.

    Result should be

    HTML Code:
    AgentName              Count of RPC
    Agent1                          2
    Agent2                          0
    Agent3                          1
    Agent4                          2
    Please Help..........
    Last edited by russel; 06-30-11 at 08:18.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT AgentName 
         , COUNT(CASE WHEN status = 'RPC'
                      THEN 'whoopee'
                      ELSE NULL END) AS `Count of RPC`
      FROM CustomerInfo
    GROUP
        BY AgentName
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2011
    Posts
    7
    thx a lot....it worked

Posting Permissions

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