 |
|
Code (SQL)
CREATE TABLE `point` (
`storeID` int,
`point` int,
`voteTime` timestamp
);
INSERT INTO `point` (`storeID`, `point`) VALUES
(1,5),(1,2),(1,5),(1,4),(1,5),
(2,5),(2,4),
(3,5),(1,3),
(4,5),(4,2),
(5,5),(1,1);
Code (SQL)
SELECT `storeID`, (`sumscore`/`cnt`) AS 'avg_score' FROM (SELECT `storeID`, SUM(`point`) AS 'sumscore', COUNT(`storeID`) AS 'cnt' FROM `point` GROUP BY `storeID`) dd
|
 |
 |
 |
 |
Date :
2014-04-30 21:39:00 |
By :
itpcc |
|
 |
 |
 |
 |
|
|
 |