PC Review


Reply
Thread Tools Rate Thread

most frquent substring

 
 
vjp2.at@at.BioStrategist.dot.dot.com
Guest
Posts: n/a
 
      20th Jul 2012
If I have a list of phone numbers by district and I want the most frequent
exchange (forst six of ten digits) for each district, what is the syntax that
would work with MS ACCESS 2007?



- = -
Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
http://www.panix.com/~vjp2/vasos.htm
---{Nothing herein constitutes advice. Everything fully disclaimed.}---
[Homeland Security means private firearms not lazy obstructive guards]
[Urb sprawl confounds terror] [Phooey on GUI: Windows for subprime Bimbos]




 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      20th Jul 2012
(E-Mail Removed) wrote:
> If I have a list of phone numbers by district and I want the most
> frequent exchange (forst six of ten digits) for each district, what
> is the syntax that would work with MS ACCESS 2007?
>
>
>

Select top 1 left(phonenum,6) as exchange, count(*) as total
from table
group by left(phonenum,6)
order by count(*) desc


 
Reply With Quote
 
 
 
 
vjp2.at@at.BioStrategist.dot.dot.com
Guest
Posts: n/a
 
      24th Jul 2012
But my problem is that this gives me the most freq exchange for everything,
that than for each region (ED,AD). I tried pivoting it (AD, vs ED, with
MAX(COUNT) but it didn't work)

SELECT top 1 Left([qvot12].[Phone],7) AS FonXcg
FROM qvot12
GROUP BY qvot12.AD, qvot12.ED,Left([qvot12].[Phone],7)
HAVING Not IsEmpty("Phone")
ORDER BY Count(Left([qvot12].[Phone],7)) DESC;


- = -
Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
http://www.panix.com/~vjp2/vasos.htm
---{Nothing herein constitutes advice. Everything fully disclaimed.}---
[Homeland Security means private firearms not lazy obstructive guards]
[Urb sprawl confounds terror] [Phooey on GUI: Windows for subprime Bimbos]




 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      24th Jul 2012
(E-Mail Removed) wrote:
> But my problem is that this gives me the most freq exchange for
> everything, that than for each region (ED,AD). I tried pivoting it
> (AD, vs ED, with MAX(COUNT) but it didn't work)


So ED and AD are field names? Two fields are needed to designate a region?
OK ...

What follows is not a pivot, it's a revised group by statement.

>
> SELECT top 1 Left([qvot12].[Phone],7) AS FonXcg
> FROM qvot12
> GROUP BY qvot12.AD, qvot12.ED,Left([qvot12].[Phone],7)
> HAVING Not IsEmpty("Phone")
> ORDER BY Count(Left([qvot12].[Phone],7)) DESC;
>
>



select AD, ED, Left([Phone],7) AS FonXcg
,Count(*)
FROM qvot12
WHERE Phone is not null
GROUP BY AD, ED,Left([Phone],7)
ORDER BY Count(*) DESC;

If this fails to give you what you want, you will need to provide a few rows
of sample data in tabular format, followed by the desired results from that
sample data, also in tabular format.


 
Reply With Quote
 
 
 
Reply

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
search text for substring and change text colour of substring Carni Microsoft Excel Discussion 5 26th Oct 2011 07:42 PM
String Manipulation - Substring, VB function Left, "length safe" Substring kellygreer1 Microsoft C# .NET 6 29th Oct 2006 09:12 PM
regular expression to match substring xxx and not substring yyy likong@email.com Microsoft C# .NET 6 9th Dec 2005 07:30 PM
RegEx search for a substring within a substring colinhumber@gmail.com Microsoft C# .NET 3 3rd Aug 2005 05:29 PM
XP frquent crashes Chris Hobson Windows XP Hardware 1 12th Jan 2004 06:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:38 AM.