SUM, strange results
Helo,
I have a problem with query
SELECT SUM(r.cena) AS cena,r.kartica,o.naziv2,o.id FROM `helios_osebe` o, `helios_racuni` r where o.kartica=r.kartica GROUP BY kartica ORDER BY cena DESC
Where helios_osebe is
CREATE TABLE `helios_osebe` (
`naziv` int(11) NOT NULL default '0',
`naziv2` varchar(100) NOT NULL default '',
`naslov` text NOT NULL,
`posta` int(11) NOT NULL default '0',
`drzava` varchar(100) NOT NULL default '',
`tel` varchar(100) NOT NULL default '',
`mob` varchar(100) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
`davcna` varchar(100) NOT NULL default '',
`spol` tinyint(4) NOT NULL default '0',
`rojstvo` date NOT NULL default '0000-00-00',
`kartica` int(11) NOT NULL default '0',
`prvaprijava` tinyint(1) NOT NULL default '0',
`sprememba` tinyint(4) NOT NULL default '0',
`id` int(11) NOT NULL default '0'
) TYPE=MyISAM;
and helios_racuni
CREATE TABLE `helios_racuni` (
`kartica` int(11) NOT NULL default '0',
`kljuc` varchar(100) NOT NULL default '0',
`datum` date NOT NULL default '0000-00-00',
`vrednost` float NOT NULL default '0',
`zaplacilo` float NOT NULL default '0',
`popust` float NOT NULL default '0',
`ident` varchar(100) NOT NULL default '',
`naziv` varchar(100) NOT NULL default '',
`kol` int(11) NOT NULL default '0',
`em` varchar(100) NOT NULL default '',
`cena` float NOT NULL default '0',
`davek` float NOT NULL default '0',
`id` int(11) NOT NULL default '0'
) TYPE=MyISAM;
There are 286 records in helios_racuni and 1426 records in helios_osebe
Results i sometime get are like
100000 100287 Naziv1 70
104055 100573 Naziv2 1122
100000 100671 Naziv3 1180
10000 100823 Naziv4 1177
10000 101436 Naziv5 1342
10000 100559 Naziv6 1152
10000 100907 Naziv7 1159
10000 100620 Naziv8 1149
Problem is that the first colum is not calculated right.
Sometimes the results are corect.
On test server with same MySQL and same data i don't have any problems. But on hosting server of hosting company this shi** is coming out.
Are there any common problems with that, i could report to hosting company, becouse they say that they can't do anything.
Version of MySQL is 4.0.25
Thank you for helping me.
Domen