zoukankan      html  css  js  c++  java
  • mysql

    SQL 常用函数集合

    --join函数具体的使用方法,对应的数据表,必须在同一个数据库中
    SELECT vt.called_no,cr.check_total_label_list,cr.check_label_list,vt.voice_id,cr.partition_dt
    FROM ailab_vqc.check_result_201908 as  cr 
    JOIN  ailab_vqc.voice_tab_201908  as vt ON cr.voice_id=vt.voice_id
    WHERE cr.check_status=0  AND vt.biz_model_type=4 and  cr.partition_dt="2019-08-30" 
    
    
    --count(*)通计数据
    SELECT count(*)
    FROM ailab_vqc.check_result_201908 as  cr 
    JOIN  ailab_vqc.voice_tab_201908  as vt ON cr.voice_id=vt.voice_id
    WHERE   vt.biz_model_type= 4  and cr.partition_dt="2019-08-26" 
    
    --where子式的写法
    SELECT vt.called_no,cr.ai_total_label_list,cr.request_id,cr.ai_label_list,cr.partition_dt
    FROM ailab_vqc.check_result_201908 as  cr 
    JOIN  ailab_vqc.voice_tab_201908  as vt ON cr.voice_id=vt.voice_id
    WHERE vt.bsp_org_id in ('20150708121351745f91d3',
    '20150708130651747bc096',
    '2015070813072616d94b3b',
    '201507081307534748251d'
    )   and vt.call_time_length > 60 AND  cr.partition_dt="2019-08-27" 
    
    --between 子式的写法
    select result.request_id, sample.editor_sentence_label_list,result.ai_sentence_label_list,sample.editor_asr_fix
    from ailab_vqc.check_result_sample sample
    join ailab_vqc.check_result_201909 result on sample.request_id = result.request_id 
    and sample.paritition_dt='20190902' and result.partition_dt="20190902" and result.check_status=0 and sample_time BETWEEN "2019-09-05 08:00:00.0" and "2019-09-05 18:00:00.0"
      
    ---各种嵌套,输出在20190322日,被叫的号码中,截止到20190626,输出成单的号码和对应成单的日期;数据表限制数据在20000以内
    select call_no_table.rt_called_no, oi.earliest_order_date
    from (select rt_called_no from defaultdb.realtime_call_detail where partition_dt = "20190322" and rt_call_time_length > 0 
    and rt_call_type = "dialout" and rt_product_line in (55,56) group by rt_called_no LIMIT 200000) call_no_table 
    join guessulike.ai_voice oi on call_no_table.rt_called_no = oi.phone
    where oi.partition_dt = "20190626" and oi.earliest_order_date > "2019-03-22"
    
    ---group by的用法,这个相当于去重
    select rt_called_no from defaultdb.realtime_call_detail where partition_dt = "20190322"  group by rt_called_no
    
    ---group by的用法,查找某个部门有多少人
    select dept,count(*) as 人数 from emp. group by dept;
    
    ---选取name中含有k的记录
    SELECT * FROM table_  WHERE name LIKE '%k%';
  • 相关阅读:
    bzoj1638[Usaco2007 Mar]Cow Traffic 奶牛交通*
    元类练习题
    元类(metaclass)
    面向对象进阶——内置方法(二)
    面向对象进阶——内置方法
    类的方法练习——定义MySQL类
    面向对象进阶——类中的方法
    面向对象三大特性——封装(含property)
    面向对象三大特性——多态(含鸭子类型)
    面向对象三大特性——继承高阶(接口和抽象类)
  • 原文地址:https://www.cnblogs.com/AntonioSu/p/11845136.html
Copyright © 2011-2022 走看看