Quote:
Originally posted by trieder
What exactly do you need to get out of the query?
|
I want to gruop the records by 2 fields, score and playdatetime
finally I solved the problem.
Thanks anyway
set @now:=now();
set @cut1:=date_add(@now, interval -3 day);
set @cut2:=date_add(@now, interval -7 day);
set @userlogin:='buyer';
select
score,
playdatetime > @cut1 as d1,
playdatetime > @cut2 && playdatetime <= @cut1 as d2,
playdatetime <= @now as d3,
count(*) as playcount,
count(distinct(game_name)) as gamecount
from TableScore
where userlogin = @userlogin
group by score,
playdatetime > @cut1,
playdatetime > @cut2 && playdatetime <= @cut1,
playdatetime <= @now;