DRRAM
asked on
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
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
What scripting language, is the information already in a particular file format or are you hoping to capture this information as well.
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
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
@DRRAM
You have SQL as one of the zones for this question. Is your data already in a database? If so, which one?
You have SQL as one of the zones for this question. Is your data already in a database? If so, which one?
ASKER
EXCEL OR MYSQL
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thx verry good
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:
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
ASKER
thank you very much is perfect