Quote:
Originally Posted by Elven
Здравствуйте, не могли бы вы подсказать где хранится в базе информация по Фестивалю Тьмы? А именно, список участников обеих сторон в каждой группе, количество набранных очков, максимальные очки за период.
Поискал в lin2world в таблицах dbo.ssq_* но не разобрался.
Хотел бы вывести эти данные на сайт в режиме онлайн.
|
о какие люди. привет

заведи stored procedure вроде такой
и в целом для сайта лучше использовать хранимые процедуры а не кучу мелких запросов. Мой вариант для счета ssq как есть на офф сайте.
Code:
set ANSI_NULLS OFF
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[site_GetSSQ]
AS
SET NOCOUNT ON
declare @dawn_collected_point int
declare @dawn_main_event_point int
declare @twilight_collected_point int
declare @twilight_main_event_point int
declare @current_round_number int
select @current_round_number = max(round_number) from lin2world..ssq_data
select @dawn_collected_point = case when dawn_point + twilight_point = 0 then 0 else ((convert(float, dawn_point) / (dawn_point + twilight_point)) * 500) end,
@twilight_collected_point = case when dawn_point + twilight_point = 0 then 0 else ((convert(float, twilight_point) / (dawn_point + twilight_point)) * 500) end
from
(
select sum(dawn) dawn_point, sum(twilight) twilight_point
from
(select
case when type = 1 then sum(collected_point) else 0 end twilight,
case when type = 2 then sum(collected_point) else 0 end dawn
from lin2world..ssq_join_data
where round_number = @current_round_number
group by type
) as a
) as b
select @dawn_main_event_point = sum(dawn), @twilight_main_event_point = sum(twilight)
from
(
select
case when ssq_part = 1 then sum(point) else 0 end twilight,
case when ssq_part = 2 then sum(point) else 0 end dawn
from
(
select
case
when sum_point > 0 then 1 -- if sum(point) is positive, twilight wins!!!
when sum_point < 0 then 2 -- if sum(point) is negative, dawn wins!!!
else 0 end ssq_part, -- even, none wins
case when room_no = 1 then 60
when room_no = 2 then 70
when room_no = 3 then 100
when room_no = 4 then 120
when room_no = 5 then 150
else 0 end point
from
(
select room_no, sum(point) sum_point -- twilight point + dawn point
from
(
select room_no,
case
when ssq_part = 1 then point -- twilight point
when ssq_part = 2 then -point -- dawn point
else 0 end point
from lin2world.[dbo].time_attack_record
where record_type > 0
and ssq_round = @current_round_number
) as x
group by room_no
) as y
) as a
group by ssq_part
) as b
select top 1 round_number, @twilight_main_event_point + @twilight_collected_point twilight_point, @dawn_main_event_point + @dawn_collected_point dawn_point,
cast(seal1 as int) as seal1, cast(seal2 as int) as seal2, cast(seal3 as int) as seal3, cast(status as int) as status, cast((datediff(s, '1970-01-01', getutcdate())-event_start_time)/60/60 as int) as hours,@twilight_main_event_point twilight_main_event_point, @dawn_main_event_point dawn_main_event_point,@twilight_collected_point twilight_collected_point,@dawn_collected_point dawn_collected_point
from lin2world.[dbo].ssq_data
where round_number = @current_round_number