Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-14-2012, 08:54 AM   PM User | #1
Vxrcorsa90
New to the CF scene

 
Join Date: Sep 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Vxrcorsa90 is an unknown quantity at this point
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 !
Vxrcorsa90 is offline   Reply With Quote
Old 09-14-2012, 04:35 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,364
Thanks: 18
Thanked 348 Times in 347 Posts
sunfighter is on a distinguished road
Use Agent = "agent_name" and see what you get.
sunfighter is offline   Reply With Quote
Old 09-14-2012, 04:55 PM   PM User | #3
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
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.
guelphdad is offline   Reply With Quote
Old 09-14-2012, 10:06 PM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,168
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:35 AM.


Advertisement
Log in to turn off these ads.