柬埔寨做网站网站在那边违反吗,关于网站开发的评审时间安排,黑马程序员培训机构官网,canva在线设计平台目录 1. 相关知识点2. 例子2.6. 使用唯一标识码替换员工ID2.7- 产品销售分析 I2.8 - 进店却未进行过交易的顾客2.9 - 上升的温度2.10 - 每台机器的进程平均运行时间2.11- 员工奖金2.12-学生们参加各科测试的次数2.13-至少有5名直接下属的经理2.14 - 确认率 1. 相关知识点 left … 目录 1. 相关知识点2. 例子2.6. 使用唯一标识码替换员工ID2.7- 产品销售分析 I2.8 - 进店却未进行过交易的顾客2.9 - 上升的温度2.10 - 每台机器的进程平均运行时间2.11- 员工奖金2.12-学生们参加各科测试的次数2.13-至少有5名直接下属的经理2.14 - 确认率  1. 相关知识点 left join 以左表为基准返回左表中所有的行同时返回右表中与左表匹配的行。如果右表中没有匹配的行则用NULL填充。  join和left join的区别 如果是join则右侧的数据有的就插没的就啥也不干交白卷也不留null但是left join让右侧数据在没有对应数据时补上了null  CROSS JOIN产生了一个结果集该结果集是两个关联表的行的乘积 2行表,与3行表使用cross join,得到2*36行数据  相关函数 函数例子含义DATEDIFF(前后)DATEDIFF(‘2007-12-31’,‘2007-12-30’); # 1两个日期的差前-后sum()sum(salary根据分组求和if (判断条件符合赋值不符合赋值)if (salary1000,1,0)根据if条件语句取值sum(if( ))sum( if (salary1000,1,0))根据if条件语句赋值再根据分组求和avg(if( ))avg( if (salary1000,1,0))根据if条件语句赋值再根据分组求均值round(,n)round(salary,3)保留n位小数 
2. 例子 
2.6. 使用唯一标识码替换员工ID select unique_id,name 
from Employees e left join EmployeeUNI e1 
on e.ide1.id;2.7- 产品销售分析 I select product_name,year,price
from Sales left join Product 
on Sales.product_id  Product.product_id;2.8 - 进店却未进行过交易的顾客 -- 顾客可能光顾了购物中心但没有进行交易,一个顾客可能光顾多次需用顾客id分组
-- 使用COUNT(*)可以输出GROUP BY后每个分组中的数据数量
-- 左连表右表没有的数据赋值为null,即没有交易的transaction_id 为nullselect v.customer_id,count(*) as count_no_trans
from Visits v left join Transactions t on v.visit_idt.visit_id
where t.transaction_id is null group by v.customer_id;2.9 - 上升的温度 -- 找出与之前昨天的日期相比温度更高的所有日期的 id
-- DATEDIFF(2007-12-31,2007-12-30);   # 1
-- DATEDIFF(2010-12-30,2010-12-31);   # -1select w1.id 
from Weather w1, Weather w2
wheredatediff(w1.recordDate,w2.recordDate)1 and w1.temperaturew2.temperature;2.10 - 每台机器的进程平均运行时间 -- sum(if(activity_type  end,timestamp ,-timestamp ))
-- 如果activity_type为“end”,值为timestamp为“start” 为-timestamp所有数相加end-start
-- count(distinct process_id),获取同一机器有几个进行idselect machine_id , round(sum(if(activity_type  end,timestamp ,-timestamp ))/count(distinct process_id),3) as processing_time 
from Activity 
group by machine_id;-- AVG(IF(activity_type  start, -timestamp, timestamp))
-- 如果activity_type为“end”,值为timestamp为“start” 为-timestamp所有数相加end-start
-- 将所有数求平均avg(1,2,3,4)/4多除了2倍SELECT machine_id, ROUND(AVG(IF(activity_type  start, -timestamp, timestamp))*2,3) AS processing_time 
FROM Activity 
GROUP BY machine_id;2.11- 员工奖金 -- join和left join的区别
-- 如果是join则右侧的数据有的就插没的就啥也不干交白卷也不留null
-- 但是left join让右侧数据在没有对应数据时补上了null
select e.name,b.bonus
from Employee e left join bonus b
on e.empIdb.empId
where b.bonus 1000 or b.bonus is null;2.12-学生们参加各科测试的次数 -- 学生表中id是唯一的将他作为主表
--  CROSS JOIN产生了一个结果集该结果集是两个关联表的行的乘积
-- 2行表,与3行表使用cross join,得到2*36行数据
select st.student_id, st.student_name,su.subject_name,count(e.subject_name) AS attended_exams 
from Students st 
cross join Subjects su 
left join Examinations e 
on e.student_idst.student_id and e.subject_namesu.subject_name
group by st.student_id, st.student_name,su.subject_name 
order by st.student_id,st.student_name;2.13-至少有5名直接下属的经理 select name
from Employee 
where id in (select managerId  -- 查找大于5的经理idfrom Employeegroup by managerId  -- 根据id分组having count(*)5); -- 根据分组的数据进行求个数2.14 - 确认率 -- s为注册表有所有用户的信息即为主表
select s.user_id,round(sum(if(actionconfirmed,1,0))/count(s.user_id),2) confirmation_rate 
from Signups s 
left join Confirmations c 
on s.user_id c.user_id 
group by s.user_id;