SORTING PCS IN SITES (NUMBER)

Please I need a script that gives me as a result the number of computers located in a site :
Example :
I have :
Scope                      Start IP Address End IP Address
[12.182.1.0] SITE 1      12.182.1.11 12.182.1.30
[12.182.8.0] SITE 2      12.182.8.130 12.182.8.254
and I have :
Name-PC   IP Address
 PC1   12.182.1.17
 PC2   12.182.8.144
 PC3   12.182.1.19
 PC4   12.182.1.29
I will find the number of computers that are in the site 1 and site 2 ...
 thank you very much in advance
DRRAMAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

matrixnzCommented:
What scripting language, is the information already in a particular file format or are you hoping to capture this information as well.
mlmccCommented:
Are you trying to do this in SQL?

If so you could do something like

SELECT * FROM YourTable WHERE Site = 1 ORDER BY IP
UNION ALL
SELECT * FROM YourTable WHERE Site = 2 ORDER BY IP

mlmcc
aikimarkCommented:
@DRRAM

You have SQL as one of the zones for this question.  Is your data already in a database?  If so, which one?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

DRRAMAuthor Commented:
EXCEL OR MYSQL
aikimarkCommented:
the general SQL would look like this:
Select Scope, Count(Scope) As SiteCount
From SiteTable, IP_Log
Where Ip_Log.[IP Address] Between SiteTable.[Start IP Address] And SiteTable.[End IP Address]
Group By Scope

Open in new window


Note: This is generic SQL and may need to be tweaked for MySQL.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DRRAMAuthor Commented:
Thx verry good
aikimarkCommented:
you're welcome.

Please be aware that the SQL solves the problem as stated.  If you throw different data into the mix, you might not get the desired results.  The reason for this is that the [IP Address], [Start IP Address], and [End IP Address] values are strings.  As such, the Between operator might not find the correct slot, if any, for the rows to be joined.

If you need to configure this for regular production use, you should probably store these ranges as BigInt values and use the INET_ATON() function to compare the IP addresses numerically.  While you could invoke the  INET_ATON() function on the range values, it would make for very inefficient queries.

http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_inet-aton

Example:
Select Scope, Count(Scope) As SiteCount
From SiteTable, IP_Log
Where INET_ATON(Ip_Log.[IP Address]) Between SiteTable.[Start IP Address] And SiteTable.[End IP Address]
Group By Scope

Open in new window

DRRAMAuthor Commented:
thank you very much  is perfect
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Algorithms

From novice to tech pro — start learning today.