select receiving.ref_id as 'po單', receiving.receiving_code as 'asn號', receiving.contact as '採購員',
(case receiving.category
when 51 then '手機電子'
when 52 then '汽摩配'
when 53 then '家居裝飾'
when 54 then '運動'
when 55 then '服裝'
when 56 then '珠寶'
when 57 then '玩具'
when 58 then '婚慶'
when 59 then '手工'
when 60 then '園藝'
when 61 then '愛好'
when 62 then '美妝'
when 63 then '電腦電子'
when 64 then '寵物燈飾'
when 65 then '騎行漁具'
when 66 then '戶外'
when 67 then '摩配'
when 68 then '消費電子'
when 69 then '娃娃配件'
when 70 then '廚衛家電'
when 71 then '服裝配件'
when 72 then '家居用品'
when 73 then '工業'
when 74 then '縫紉'
when 75 then '個護'
when 76 then '收藏'
when 77 then '遊戲攝影'
when 78 then '樂器'
when 79 then '商業'
when 80 then '嬰幼'
end) as '品類', receiving_pre.rp_receiving_time as '收貨時間',
(case receiving_pre.rp_qclevel
when 1 then '緊急'
else '常規'
end) as '收貨時asn優先順序', receiving_pre_map.rpm_unpack_time as '開箱時間',
(case receiving.asn_level
when 1 then '緊急'
else '常規'
end) as '開箱時asn優先順序' from receiving_pre join receiving_pre_map on receiving_pre.rp_tracking_number=receiving_pre_map.rp_tracking_number join receiving on receiving_pre_map.receiving_code=receiving.receiving_code where receiving_pre.rp_receiving_time>='2019-09-14 00:00:00' and receiving_pre.rp_receiving_time<='2019-10-15 00:00:00';
結果:
sqlite變更字段型別
因為sqlite不能完全支援sql語句,只能增加字段,不能drop欄位,所以,要修改某錶的某欄位資料型別,只能 alter table tbacct rename to tbacctold 先將表重新命名 create table tbacct id integer primary key auto...
sql字段值的替換
資料庫有一張表bug 缺陷記錄表 裡面有欄位severity 嚴重程度 severity的值實際為1,2,3,4,但希望在查詢結果中將severity的1,2,3,4值顯示為其他的值,但severity的實際值不會改變 例如 資料表的結構和資料如下 bug id name severity 1 張三...
SQL語句實現資料表的字段值橫向顯示
用sql實現由原表a到目標表b的轉換,將原表a中cc列的值做為目標表b的字段,目標表b新建欄位的值為原表a中對應的 value值,如以下兩表。原表aid cc value 1 d 100 2 d 200 3 d 300 1 e 1000 2 e 2000 3 e 3000 1 f 10 2 f 20...