請問 SQL 高手

來源: youngfather 2009-06-16 16:36:44 [] [舊帖] [給我悄悄話] 本文已被閱讀: 次 (555 bytes)
下麵這樣的情況是不是可以用一句query 出來?

從一個表 :
orderid,storeid,itemid,quantity,date

導出另外一個表:
colum1: 下麵是itemname1,itemname2,itemname3......

colum2: TH->storeid1 ,然後下麵是 quantity1(對應itemname1),quantity2(對應itemname2),quantiy3(對應itemname3).......

colum3: TH->storeid2, 然後下麵是 quantity1(對應itemname1),quantity2(對應itemname2),quantity3(對應itemname3)........
.
.
.
columend:TH->total, 然後下麵是 total1(for quantity1),total2(for quantity2),...

請問這個怎樣實現 ?thanks!

所有跟帖: 

你是要一個報表,最後一行是前麵各行的求和,是嗎? -布衣之才- 給 布衣之才 發送悄悄話 布衣之才 的博客首頁 (36 bytes) () 06/16/2009 postreply 17:44:38

回複:請問 SQL 高手 -XDJM1234- 給 XDJM1234 發送悄悄話 (122 bytes) () 06/16/2009 postreply 17:50:51

回複:回複:請問 SQL 高手 -布衣之才- 給 布衣之才 發送悄悄話 布衣之才 的博客首頁 (152 bytes) () 06/16/2009 postreply 18:10:20

if oracle, #2: just use rollup() groupiing -lambada- 給 lambada 發送悄悄話 (0 bytes) () 06/16/2009 postreply 17:59:06

回複:if oracle, #2: just use rollup() groupiing -布衣之才- 給 布衣之才 發送悄悄話 布衣之才 的博客首頁 (29 bytes) () 06/16/2009 postreply 18:13:00

你的這些表首先要 Normalize 幾下子哈。。。 -多哥- 給 多哥 發送悄悄話 (0 bytes) () 06/16/2009 postreply 18:49:14

他好像就一個表吧,後麵說的都是取出來的columns and rows -布衣之才- 給 布衣之才 發送悄悄話 布衣之才 的博客首頁 (0 bytes) () 06/16/2009 postreply 18:51:02

fact table(s), dimension(s)... -HappyNow?!- 給 HappyNow?! 發送悄悄話 HappyNow?! 的博客首頁 (51 bytes) () 06/16/2009 postreply 18:58:40

請問:SQL的就業機會多嗎?都在什麽領域? -coolwin- 給 coolwin 發送悄悄話 (57 bytes) () 06/16/2009 postreply 23:38:29

回複:請問 SQL 高手 -tapisapi2008- 給 tapisapi2008 發送悄悄話 (142 bytes) () 06/18/2009 postreply 18:12:32

How many stores are there? -萬見愁- 給 萬見愁 發送悄悄話 (744 bytes) () 06/21/2009 postreply 00:30:31

請您先登陸,再發跟帖!

發現Adblock插件

如要繼續瀏覽
請支持本站 請務必在本站關閉/移除任何Adblock

關閉Adblock後 請點擊

請參考如何關閉Adblock/Adblock plus

安裝Adblock plus用戶請點擊瀏覽器圖標
選擇“Disable on www.wenxuecity.com”

安裝Adblock用戶請點擊圖標
選擇“don't run on pages on this domain”