Public feed #887408

Anonymous

public text v1 · immutable
Raw Edit
·published 2008-02-01 09:04 UTC
rendered paste body
User individual hitcount:

(
	SELECT visitDay, visitCount
	FROM statistic_history_visitor
	WHERE userId = {$userId}
		AND visitYear = {$year}
		AND visitMonth = {$month}
		AND visitDay BETWEEN 1 AND {$lastDay}
)

UNION

(
	SELECT DAY( visitTime ) AS visitDay, COUNT( * ) AS visitCount
	FROM statistic_daily_visitor
	WHERE userId = {$userId}
	GROUP BY DAY( visitTime )
)

ORDER BY visitDay ASC;



Top 10 hitcount:

SELECT u.username, i.gender, SUM( v.visitCount ) AS receivedCount
FROM statistic_history_visitor AS v
	JOIN user AS u ON v.userId = u.userId
	JOIN user_info AS i ON v.userId = i.user_id
WHERE v.visitYear = {$year}
	AND v.visitMonth = {$month}
GROUP BY v.userId
ORDER BY receivedCount DESC
LIMIT 10;