[SQL ] 計算數量問題

看板Database (資料庫)作者 (英文很重要?!)時間18年前 (2008/03/15 17:38), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/3 (看更多)
只要path 是/eorder開頭且id相同的只取一筆的數量有多少 table: path id ------------------------------------ /eorder/step1.asp 190471982 /news/combo.asp 190472310 /index.asp 190472325 /index.asp 192491668 /hotcard/sale.asp 192491665 /eorder/step1_delco.asp 190471982 /eorder/step1.asp 192491315 /menu/new.asp 190472209 例如 : 都是/eorder開頭的資料 /eorder/step1.asp 190471982 /eorder/step1_delco.as 190471982 /eorder/step1.asp 192491315 但前兩筆的id相同 所以數量為=2 怎麼下SQL 語法呢?? 謝謝 我知道可以由substring(path,1,7)='/eorder' 取出/eroder開頭的資料 select count(path) 其他的就不知道該怎麼處理了 有人會的嗎?請指教一下 謝謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.70.165.248

03/15 20:46, , 1F
select count(distinct id) from 表 where 選擇條件
03/15 20:46, 1F

03/17 21:46, , 2F
會了~謝謝囉
03/17 21:46, 2F
文章代碼(AID): #17svZxa6 (Database)
文章代碼(AID): #17svZxa6 (Database)