MySQL
- 32 ответа
 - 0 вопросов
 
    20
    Вклад в тег
    
      
      
    
  
  
select s.Name
     , sum(nvl(o.Amount, 0)) as Quantity
  from Sellers as s,
          Orders as o
 where s.id = o.Salesperson_id 
   and o.Order_date is not null 
   and o.Order_date > to_date('20091231','YYYYMMDD') /*если это date*/
 group by s.id, s.Name
having count(o.Salesperson_id) > 1
 order by sum(nvl(o.Amount, 0)) desc
offset 0 rows fetch next 1 rows onlySELECT * FROM `tab` WHERE id in (2,3,1)
order by find_in_set (id, '2,3,1')      SELECT 
strftime('%Y', case Dub_date when 'Reg' then reg_date else terminate_date end) AS Date_,
count(case Dub_date when 'Reg' then reg_date end) AS opened_count,
count(case Dub_date when 'Terminate' then terminate_date end) As terminate_count
  FROM COMPANIES, (select 'Reg' Dub_date union all select 'Terminate')
group by Date_
having Date_ is not null