MySQL
vincentgoodturtle
这个作者很懒,什么都没留下…
展开
-
使用INNER JOIN 比較今日和前一日的數據
select t1.*, t2.* from employees t1 inner join employees t2 on t1.emp_no = t2.emp_no -1 limit 5;原创 2019-06-12 20:28:02 · 84 阅读 · 0 评论 -
建立索引
優化MySQL查詢的其中一個方法是添加索引。--添加索引的語句如下:create index **index_name** on **table_name** (**column_name**);--刪(月弓)(刀字邊用打弓)除索引:drop index index_name on table_name;例子: create index first_name_index on empl...原创 2019-06-12 20:41:27 · 122 阅读 · 0 评论 -
SQL 查詢和Excel Pivot Table比較
Excel Pivot Table 適合沒有寫SQL能力的人去查詢數據而SQL是一個數據庫儲存大量數而百萬, 千萬計的數據。使用Pivot Table會較易實現SQL功能, 免去了寫SQL語句的麻煩。可是Excel是適用於處理最大300mb左右的數據。例子如retension rate。計算留存率可以Excel和SQL查詢。...原创 2019-06-12 20:46:38 · 310 阅读 · 0 评论 -
LeetCode 197
這裡要用到inner join 取得previous date 的數據。所有INNER JOIN 連接所有數據後設定filter條件: DATEDIFF(t1.Date, t2.Date)=1原创 2019-06-12 23:02:33 · 92 阅读 · 0 评论 -
MySQL學習
語法:show databases;use database name;show tables;use table name;update table_name set column1_name = column1_value where column2_name = column2_value原创 2019-06-09 14:29:08 · 65 阅读 · 0 评论 -
where xxx group by VS group by having xxxx
where xxx group by 代表 在group by 之前filter 數據group by having xxx 代表在group by 之後filter 數據原创 2019-06-12 00:36:06 · 307 阅读 · 0 评论