Test

Материал из noname.com.ua
Перейти к навигацииПерейти к поиску
select  
 if (dv.logins=0, if(tp.logins is null, 0, tp.logins), dv.logins) AS logins,  
 if(dv.filter_id != '', dv.filter_id, if(tp.filter_id is null, '', tp.filter_id)),  
 if(dv.ip>0, INET_NTOA(dv.ip), 0),  INET_NTOA(dv.netmask),  
 dv.tp_id,  
 dv.speed,  
 dv.cid,    
 tp.total_time_limit,  
 tp.day_time_limit,  
 tp.week_time_limit, 
 tp.month_time_limit,  
 UNIX_TIMESTAMP(DATE_FORMAT(DATE_ADD(curdate(), INTERVAL 1 MONTH), '%Y-%m-01')) - UNIX_TIMESTAMP(),  
 tp.total_traf_limit,  
 tp.day_traf_limit,  
 tp.week_traf_limit,  
 tp.month_traf_limit,  
 tp.octets_direction,  
 if (count(un.uid) + count(tp_nas.tp_id) = 0, 0,    if (count(un.uid)>0, 1, 2)),UNIX_TIMESTAMP(),  UNIX_TIMESTAMP(DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP()), '%Y-%m-%d')), DAYOFWEEK(FROM_UNIXTIME(UNIX_TIMESTAMP())),  DAYOFYEAR(FROM_UNIXTIME(UNIX_TIMESTAMP())),  
dv.disable,  
tp.max_session_duration,  
tp.payment_type,  
tp.credit_tresshold, 
tp.rad_pairs,  
count(i.id),  
tp.age,  
dv.callback,  
dv.port,  
tp.traffic_transfer_period,  
tp.neg_deposit_filter_id,  
tp.ext_bill_account,  
tp.credit,  
tp.ippool,dv.join_service,  
tp.tp_id     
FROM 
 (dv_main dv)     
LEFT JOIN 
 tarif_plans tp 
ON 
 (dv.tp_id=tp.id AND tp.domain_id='0')     
LEFT JOIN 
 users_nas un 
ON 
(un.uid = dv.uid)     
LEFT JOIN 
 tp_nas 
ON 
 (tp_nas.tp_id = tp.tp_id)
LEFT JOIN 
intervals i 
ON 
(tp.tp_id = i.tp_id)     WHERE dv.uid='1720'GROUP BY dv.uid;