If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Query to display this output

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-30-11, 06:40
russel russel is offline
Registered User
 
Join Date: Jun 2011
Posts: 7
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 07:18.
Reply With Quote
  #2 (permalink)  
Old 06-30-11, 07:19
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Code:
SELECT AgentName 
     , COUNT(CASE WHEN status = 'RPC'
                  THEN 'whoopee'
                  ELSE NULL END) AS `Count of RPC`
  FROM CustomerInfo
GROUP
    BY AgentName
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 06-30-11, 07:40
russel russel is offline
Registered User
 
Join Date: Jun 2011
Posts: 7
thx a lot....it worked
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On