m1ko
Создатель
- Регистрация
- 15 Авг 2010
- Сообщения
- 42
- Реакции
- 3
- Автор темы
- #1
Добрый день, помогите пожалуйста в нелегком деле.
Структура должна получится так:
Структура должна получится так:
Код:
1. HASH (с учетом 2 таблиц)
2. name
3. Поинты (уже суммированые с 2 таблиц)
4. show1 с baza_1
5. show1 с baza_2
6. show3 с baza_1
7. show3 с baza_2
PHP:
select @row_num:=@row_num+1 hash,ttt.* from
(select tt.name,tt.aID, sum(case when tt.row_number=5 then 1 else 0 end) show1, count(*) show3 ,sum( tt.row_number) point from
(SELECT t.row_number, t.db_aIDs, t.aID, t.name FROM
(SELECT @row_number := CASE WHEN @db_aIDs = setname
THEN @row_number -1
ELSE 5
END AS row_number, @db_aIDs := setname AS db_aIDs, aID,name
FROM baza_1,
(SELECT @row_number:=5,@db_aIDs:='') AS t
ORDER BY setname, TIME
) t where t.row_number >2
) tt
group by tt.aID
order by 5 desc
) ttt, (SELECT @row_num:=0) AS tttt
PHP:
select @row_num:=@row_num+1 hash,ttt.* from
(select tt.name,tt.aID, sum(case when tt.row_number=3 then 1 else 0 end) show1, count(*) show3 ,sum( tt.row_number) point from
(SELECT t.row_number, t.db_aIDs, t.aID, t.name FROM
(SELECT @row_number := CASE WHEN @db_aIDs = setname
THEN @row_number -1
ELSE 3
END AS row_number, @db_aIDs := setname AS db_aIDs, aID,name
FROM baza_2,
(SELECT @row_number:=3,@db_aIDs:='') AS t
ORDER BY setname, TIME
) t where t.row_number >0
) tt
group by tt.aID
order by 5 desc
) ttt, (SELECT @row_num:=0) AS tttt