This is all confusing to me. How many tables are in this database
and what are they? What are the fields and to what table to they belong?
What are the field types of each one of the fields? What do you mean by
ip and serial are character arrays? Character arrays are not one of the
field types nor field properties that I know of. An example of character
arrays would be nice too.
You use the terms office 1 name, office 2 name, office 1 subtotal,
and office 2 subtotal. What are the relationships of these terms to the
fields in the database?
What I'm trying to do is to create your database to see what could
be done. But I can't do that with what you have written: I need more
specific information.
You speak of a script. Could you share that with us also?
--Dan
You are 100% correct here is a better example of data and what I'd
like as the output form with the given example.
CREATE TABLE `storename` (
`store` int(11) NOT NULL,
`storename` varchar(20) DEFAULT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `storename` VALUES (1,"store 1");
INSERT INTO `storename` VALUES (2,"store 2");
CREATE TABLE `printusage` (
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
CURRENT_TIMESTAMP,
`serial` varchar(20) NOT NULL,
`ip` varchar(15) DEFAULT NULL,
`counter` bigint(20) DEFAULT NULL,
`webcounter` bigint(20) DEFAULT NULL,
`totalprint` bigint(20) DEFAULT NULL,
`bwprint` bigint(20) DEFAULT NULL,
`copies` bigint(20) DEFAULT NULL,
`bwcopies` bigint(20) DEFAULT NULL,
`faxes` bigint(20) DEFAULT NULL,
`store` int(11) DEFAULT NULL,
PRIMARY KEY (`date`,`serial`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `printusage` VALUES ('2011-12-30
00:00:00','1','192.168.1.50',100,100,100,100,0,0,0,1);
INSERT INTO `printusage` VALUES ('2011-12-30
00:00:00','2','192.168.1.51',100,100,100,100,0,0,0,1);
INSERT INTO `printusage` VALUES ('2011-12-30
00:00:00','3','192.168.1.52',100,100,100,100,0,0,0,1);
INSERT INTO `printusage` VALUES ('2011-12-30
00:00:00','4','192.168.2.50',100,100,100,100,0,0,0,2);
INSERT INTO `printusage` VALUES ('2011-12-30
00:00:00','5','192.168.2.51',100,100,100,100,0,0,0,2);
INSERT INTO `printusage` VALUES ('2011-12-31
00:00:00','1','192.168.1.50',105,105,105,105,0,0,0,1);
INSERT INTO `printusage` VALUES ('2011-12-31
00:00:00','2','192.168.1.51',105,105,105,105,0,0,0,1);
INSERT INTO `printusage` VALUES ('2011-12-31
00:00:00','3','192.168.1.52',105,105,105,105,0,0,0,1);
INSERT INTO `printusage` VALUES ('2011-12-31
00:00:00','4','192.168.2.50',105,105,105,105,0,0,0,2);
INSERT INTO `printusage` VALUES ('2011-12-31
00:00:00','5','192.168.2.51',105,105,105,105,0,0,0,2);
example of desired output report.
store 1
IP, Serial, Counter Difference from 2011-12-30 00:00:00 to 2011-12-31 00:00:00
192.168.1.50, 1, 5
192.168.1.51, 2, 5
192.168.1.52, 3, 5
store 1 subtotal 15
store 2
IP, Serial, Counter Difference from 2011-12-30 00:00:00 to 2011-12-31 00:00:00
192.168.2.50, 4, 5
192.168.2.51, 4, 5
store 2 subtotal 10
total 25