码迷,mamicode.com
首页 > 其他好文 > 详细

leetcode收获

时间:2019-01-07 17:53:52      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:color   returns   ediff   必须   函数返回   sele   col   mit   int   

left outer join table on 
distinct唯一值,distinct必须放在开头
limit 1,1 返回第二值 
group by having count()>1 累加
SELECT  *  FROM  user  WHERE  name like CONCAT(%,#{name},%) 
DATEDIFF() 函数返回两个日期之间的时间。
UNION 用于合并两个或多个 SELECT 语句的结果集,并消去表中任何重复行
mod(N,M)该函数返回N除以M后的余数
update salary set sex=case sex when m then f else m end交换性别
创建函数:create function(,,) returns 参数类型 Begin 
return(sql); end          返回第N高的薪水  :
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
      set N=N-1;
  RETURN (
      # Write your MySQL query statement below.      
    select ( select distinct Salary as getNthHighestSalary from Employee order by Salary desc
      limit N,1 ) As getNthHighestSalary
  );
END 

 

leetcode收获

标签:color   returns   ediff   必须   函数返回   sele   col   mit   int   

原文地址:https://www.cnblogs.com/DIVEY/p/10232334.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!