随笔分类 - 数据库
摘要:select user_id, concat(upper(substring(u.name,1,1)),lower(substring(u.name,2))) as name from users u order by user_id -- CONCAT(str1, str2):字符连接函数 --
阅读全文
摘要:link select * from patients where conditions REGEXP BINARY '^DIAB1|\\sDIAB1' select * from patients where conditions like BINARY 'DIAB1%' or condition
阅读全文
摘要:link select * from users where mail regexp '^[a-zA-Z][a-zA-Z0-9_/\\.\\-]*(@leetcode.com)'
阅读全文
摘要:link select name as country from ( select name,sum(duration)/count(duration) as avg from ( select t.name,t.id, c1.caller_id, c1.callee_id, c1.duration
阅读全文
摘要:link select sell_date, count(distinct product) as num_sold, group_concat(distinct product order by product asc separator ',') as products from activit
阅读全文
摘要:link select i.item_category as category, sum(if(date_format(order_date,'%W')='Monday',quantity,0)) as 'Monday', sum(if(date_format(order_date,'%W')='T
阅读全文
摘要:link # Write your MySQL query statement below select t3.product_id,p.product_name,year as report_year,amount as total_amount from ( select product_id,
阅读全文
摘要:link Solution1: 自定义变量,union all # Write your MySQL query statement below select username,activity,startDate,endDate from ( select t1.*, @rk:=if(@name=
阅读全文
摘要:link select t3.id as transactions_count, if(t5.cnt is null,0,t5.vcnt) as visits_count from ( select t0.id from ( select @num:=@num+1 as id from (selec
阅读全文
摘要:题目链接 题解: 这道题太复杂了。。。主要是前两列最开始比较难想怎么做。 # Write your MySQL query statement below select t4.spend_date, t4.platform, if(t6.spend_date is null,0,t6.amount)
阅读全文
摘要:题目链接 题解1: 先排序,然后用自定义变量记录累计的score。 select gender,day,total from( select day, @s:=(if(gender=@g,@s+score_points,score_points)) as total, @g:=gender as g
阅读全文

浙公网安备 33010602011771号