<address id="xpjh9"><listing id="xpjh9"><meter id="xpjh9"></meter></listing></address>

<address id="xpjh9"><address id="xpjh9"><listing id="xpjh9"></listing></address></address>
<noframes id="xpjh9">
<noframes id="xpjh9">

<address id="xpjh9"><address id="xpjh9"><listing id="xpjh9"></listing></address></address>
    <form id="xpjh9"></form><address id="xpjh9"><listing id="xpjh9"><menuitem id="xpjh9"></menuitem></listing></address>

      <noframes id="xpjh9">
      VB.net 2010 視頻教程 VB.net 2010 視頻教程 VB.net 2010 視頻教程
      SQL Server 2008 視頻教程 c#入門經典教程 Visual Basic從門到精通視頻教程
      當前位置:
      首頁 > 數據庫 > T-SQL >
      • sql語句大全之T-SQL 簡易小數處理

      • 2019-05-02 10:20 來源:未知

      今天因應同事提的一則需求,寫了一段 CASE WHEN 的整數與小數處理

      過程中居然踩了個雷,特此記錄下來

      首先,需求如下:

      當內容為整數或零時則去掉尾端的小數否則就顯示原本的小數內容

      若內容為 NULL 也維持不變

      例如: 120.000 要顯示為 120 , 而 120.12345 則維持不變 

      在聽完需求後,我快速寫了以下這段 CASE WHEN 判斷

      image

      但看起來行不通阿!!! 可以看到我在 THEN 的時候直接轉成INT類型,但出來的結果還是DECIMAL類型
      此時同事說了句,是不是有可能型態在CASE WHEN時就已經決定了

      經過測試大致整理出邏輯如下

      CASE WHEN 是透過所有 THEN 值的型態優先順序,來決定最終型態為何

      當其中一個型態無法做隱含轉換時(比如像下圖的文字無法直接轉換成小數) ,就會出錯

      image

       

      而透過下列的語法,可以自行測試各種組合的最終型態的優先權為何

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      DECLARE @T DECIMAL(10,4) = 192.1233
      SELECT
      SQL_VARIANT_PROPERTY(IntAndDecimal,'BaseType'),
      IntAndDecimal
      FROM
      (
      SELECT
      CASE
      WHEN @T = FLOOR(@T)
      THEN CAST(@T as varchar)
      WHEN @T > FLOOR(@T)
      THEN CAST(@T as INT)
      WHEN @T < FLOOR(@T)
      THEN CAST(@T as decimal)
      END as IntAndDecimal
      ) X  

       從下圖可以看到當CASE WHEN 同時有 varchar 、 int 、 decimal 、 float 時

      最後會統一轉換成float型態 

       

      相關的文件可以參考官網
      https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-type-precedence-transact-sql?view=sql-server-2017

      最後

      以下就是我寫的完整語法,可以看到透過在 THEN 我分邊加了兩個 CAST 轉換

      在優先權的比較後,最後的型態會統一轉換成  Float ,所以原本會以 DECIMAL 為主的型態已經消失了


      相關的效果也可以參考兩個 Column  的值 ,最右邊為預期的結果,左邊則為原始結果

      image

      相關教程
      江苏快3 www.976616.com | jdfschool.com | www.940999.com | 3788ii.com | www.2934x.com | www.22667712.com | 4136a.com | www.09299.com | www.js5666.com | 66555156.com | www.sygj5.com | www.9699.us | 15a13.net | www.9205e.com | www.tai55.com | 88850cc.com | www.pjzxyl.cc | www.woaicp666.com | 9566279.com | www.967004.com | www.6491b.com | 1389kk.com | www.706wb.com | www.bet3650714.com | 1591yyy.com | www.550022.com | www.668778.com | ribo25.cc | www.20899.com | www.msc111.com | 94111ddd.com | www.976550.com | www.beb111.org | 506374.com | www.332760.com | www.bet91489.com | www.pu2678.com | 4997g.com | www.ya2019q.com | www.ajs5.com | y7061.com | www.606510.com | www.sb5507.com | 3178y.com | vs9777.com | www.4331c.com | www.696901.com | 463t8.com | www.912162.com | www.8861tt.com | ii5443.com | 0496556.com | www.2418j.com | www.33600.com | 3568o.com | www.558421.com | www.79095h.com | www.vn89969.com | 22225002.com | www.548477.com | www.hgdc800.com | www.625966.com | 3559s.com | www.ya488.com | www.tycp55.com | y47479.com | 3mgmooo.com | www.5522b.cc | www.55060m.com | www.4759oo.com | 3640y.com | www.c8714.com | www.009289.com | www.pjzhejiang.com | x777dl.com | www.700345.com | www.hgdc100.com | www.6491o.com | spj01.net | www.566897.com | www.4546500.com | www.777444r.com | 418626.com | www.36788o.com | www.8977500.com | www.522118.com | 00774vv.com | 2677ooo.com | www.1248g.cc | www.js89h.vip | www.hg57666.com | 6118g.com | c388o.com | www.cp8006.cc | www.99552ss.com | www.ljw036.com | jinshabet.com | r83377.com | www.863012.com | www.74737.com | www.pj5744.com | 30006f.com | 225605.com | 79889x.com | www.3416l.com | www.567678.cc | www.ao299.com | 588qqq.cc | 8294x.com | www.225075.com | www.6653f.com | www.50999k.com | www.zzzz0266.com | 2381vvv.com | ee00558.com | www.207881.com | www.50051d.com | www.9997028.com | www.22235b.com | 68348.com | 0805b.com | 73122.com | www.892070.com | www.sb8357.com | www.85857y.com | www.jsc999.com | 500000794.com | 1489m.com | 9734vip.com | www.hx6686.com | www.u98478.com | www.3550.com | www.hg3839.com | www.86611a.com | 4195n.com | m85323.net | www.39500e.com | www.23hf.com | www.607116.com | www.bwinyz13.com | www.932285555.com | www.77537q.com | 2546i.com | 5802uu.com | 13134688.com | www.529411.com | www.9818q.cc | www.9646l.com | www.js69111.com | www.304015.me | www.5303v.com | www.567pj.com | 皇冠总公司.com | 22ff940.com | 38989i.com | 97297r.com | www.599399.com | www.8667o.com | www.79955.com | www.y32031.com | www.751cp1.com | www.001472.com | www.00829q.com | 6556g.com | zzc55.com | 355233.com | 99909n.com | 2355t.com | 39992266.com | v00351.com | www.399280.com | www.ch8234.com | www.9149j.com | www.ky1007.com | www.r98478.com | www.b063801.com | www.623667.com | www.5966ddd.com | www.js815.com | www.700589.com | www.995f.net | www.900692.com | www.76543n.com | www.ks299.net | 2618h.com | 64111y.com | 046967.com | 2012bet6.com | 496ff.com | b2146.com | 61327755.com | 654.so | 2757.co | 22299qq.com | h51335.net | 78808c.com | 4369.com | 15942222.com | 112l.net | 588ttt.cc | 155.net | 79889g.com | www.22264400.com | www.vns98.com | www.10899b.com | www.365815x.com | www.u30226.com | www.825909.com | www.h7788x.com | www.900566.com | www.3339193.com | www.9566438.com | www.97780099.net | www.2302310.com | www.804171.com | www.5446zz.com | www.4828998.com | www.06820h.com | www.pjc88.vip | www.7240x.com | www.192818.com | www.87668t.com | www.6364q.com | www.989841.com | www.601497.com | www.208780.com | 5443m.com | 18887365.com | 11005c.com | 4018s.com | 28288w.com | 55818b.com | www.js1166.com | www.9679l.com | www.xpj1808.com | www.bet445.com | www.f526688.com | www.4058ii.com | www.778545.com | www.7239.net | www.897030.com | www.196902.com | xpj677s.com | 866666f.com | 0471sands.com | x3855.com | 5004jj.com | www.56520n.com | www.518008.com | www.c456x.com | www.9895j.com | www.8887989.com | www.fen08.com | www.239544.com | 6363go.com | 13222x.com | 78115577.com | www.yh77707.com | www.hg2098.com | www.35252l.com | www.wns123f.com | www.77803w.com | www.775709.com | 69-xpj.com | 91019r.net | 88w55.vip | yun8123.com | www.142357.com | www.79500s.com | www.836bbb.com | www.2373o.com | www.175709.com | 27878jj.com | 0166556.com | 69990e.com | www.40033.1540033.com | www.3550.com | www.yh7771.com | www.766859.com | 3344blg.com | 1458k.com | ks2227.com | www.rycp13.com | www.38138p.com | www.77114w.com | www.229958.com | wns880.com | ting0055.com | www.44221.com | www.89599k.com | www.880085.com | www.tcp969.com | 9j0033.com | 9649n.com | www.2846z.com | www.26123ff.com | www.50732s.com | www.100202.com | 8381j.com | zhcp70.com | www.66667666.com | www.win1231.com | www.755860.com | 9607w.vip | 28839y.com | www.701707.com | www.158024.com | www.lczg0.com | 131bbb.net | 56787hh.com | www.006087.com | www.91779t.com | www.hy5955.com | 5855dh.com | 85698a.com | www.20180077.com | www.yh8899.bet | www.493552.com | nn500g.com | www.6033k.com | www.55526u.com | www.86267r.com | 9607588.online | m0003.com | www.6662558.com | www.v1432.com | www.925771.com | 4066a.com | 6641t.com | www.58665z.com | www.66653.com | amjs9944.com | 588.cc | www.jl11111.com | www.53900h.com | 983888y.com | feicai0830.com | www.7669mm.com | www.61655x.com | hag8326.com | 2546d.com | www.168005.com | www.50989h.com | 1253-9.com | 44077w.com | www.458177.com | www.878zf.com | 58000c.com | www.517ly13.com | www.89677n.com | www.657320.com | 新2.com | www.902505.com | www.8582zz.com | 1105596.com | 2535hd.com | www.5146z8.com | www.912162.com | 0208ii.com | www.yh8402.com | www.hyi682.com | 5350s.com | www.237015.com | www.w84g.com | 138763.com | zhcp37.com | www.500.cm | www.613069.com | 5219c.com | www.770222.com | www.3890n.com | f2894.com | www.05125a.com | www.ya2019x.com | bet36500220.com | www.hg9093.com | www.78680r.com | 22966.com | hpzx88.com | www.88325i.com | 54141122.com | 9539i.com | www.73990x.com | 49114.com | xpj66378.com | www.380820.com | 6868ff.cc | www.00038js.com | www.3846g.com | 6hcc88.com | www.14555a.com | www.68993279.com | 1596e.com | www.4261144.com | www.99431.cc | 42842827.com | www.cs.bet | www.550284.com | 99567i.com | www.344654.com | 3678u.com | www.518hwx.com | www.xb88.com | 7508w.com | www.858t.com | www.500106.com | 7792i.com | www.588875.com | 377633.com | www.3643z.com | www.6832t.com | lc99r.com | www.C63.COM? | 5099ff.com | www.pj7889.com | www.50051b.com | 3890p.com | www.ggp.99233p.com | www.009275.com | www.hg12358.com | www.99638l.com | 052325.com | www.138cpp.com | www.015990.com | www.jsh922.com | www.81678r.com | 0615018.com | www.vv88ss.com | 301111.com | www.4972ss.com | www.5xca.com | 30177788.com | www.48330x.com | x2.cc | www.kb9996.com | js345345.com | www.8808000.com | www.982399.com | 6245i.com | www.sa606.com | 69448866.com | www.5250666.com | 2776b.com | www.pj8689.com | www.dcw566.com | www.445887.com | www.3478s.cc | 3122a.com | www.9646h.com | 566777x.com | www.i2894.com | 3556vip5.com | www.bet91484.com | 4508dd.com | www.114654.com | 6175uu.com | www.138ppp.com | www.377192.com | www.bb5577.com | www.915990.com | www.81866j.com | www.5086b.com | 883399g.com | www.55228c.com | 25288m.com | www.ya2019t.com | tl850.com | www.5958127.com | 146664455.com | www.4809y.com | oo8159.cc | www.d94600.com | 4303jc.com | www.2234.im | v0141.com | www.392229.com | 8037n.com | www.02737.com | 9506u.com | www.v774477.com | 18438z.com | www.8582ww.com | 20055533.com | www.26299t.com | 3225u.com | www.hjin6.com | www.pj550088.com | www.701549.com | www.1347-05.com | www.282263.com | www.tb186.com | 33382k.com | www.990654.com | 80850v.com | www.a30666.com | 9479a3.com | www.hg241.com | 50067u.com | www.00840l.com | 12742s.com | www.648689.com | www.2078l.com | 660499.com | www.500500.com | 8006009.com | www.vip81619.com | ha080.net | www.16001.com | www.hg9678.com | www.390366.com | www.hg4438.com | 55766.com | www.k7764.com | 30688z.com | www.66332s.com | www.ab943.com | www.316477.com | www.958500.com | dz825.com | www.xpj8856.com | 20772222.com | www.rcw8844.com | www.964808.com | 22betbet365.com | www.ts058.com | 34x35.com | www.75850.cc | www.33928a08.com | 56033.net | www.biying990vip.com | 8381p.com | www.27czj.com | www.60778.com | 3822c.com | www.47506q.com | 9339999d.com | www.774255.com | www.xin8884.com | 6423i.com | www.367777.cc | 1156.com | dz881.com | www.55060t.com | 91019d.com | www.890703.com | www.25288d.com | i86811.com | www.97655q.com | www.pj9909.com | 00tt8331.com | www.0088hgaa.com | 87680n.com | 5558449.com | www.9170106.com | pj990.com | www.407872.com | www.7779856.com | js345b.com | www.903588.com | www.d8007.com | 20188b.com | www.2350w.com | www.xpj661199.com | 87665m.com | www.61233pp.com | www.hg22331.com | bet99979.com | www.60996.cc | www.224333222.com | 7742ii.com | www.9818x.cc | www.6372008.com | 2222k04.com | www.hy5503.com | www.339788.com | 3559nn.com | www.638806.com | www.808888z.com | 68228y.com | www.257512.com | www.sha0033.com | 776059.com | 2767.com | www.4058.com | www.83335k.com | d2306.com | www.qucw4.com | www.cx9871.com | ambc8899.net | www.218195.com | www.245885.com | 1654hh.com | 55909.com | www.87668k.com | www.77605b.com | 86611.com | www.450568.com | www.5981g.com | 7736k.com | 78808l.com | www.39500j.com | www.001649.com | 3685w.com | www.022190.com | www.7920p.com | www.h7788d.com | mgm.am | www.725898.com | www.mgm868009.com | www.d67783.com | 9646s.com | www.451.cc | www.007ggb01.com | 44488s.com | 2078v.com | www.4189b.com | www.dzcp3333.com | 2190.com | 7893w41.com | www.hm6622.com | www.50999u.com | 58802l.com | 52688s.com | www.928621.com | www.35700d.com | www.yh03456.com | 1443b.com | www.371957.com | www.8350.vip | www.kk8996.com | 553388.com | 22xx8332.com | www.2934o.com | www.00618d.com | www.aobo8866.com | 2222k27.com | www.444081.com | www.hbet97.com | www.hg00868.com | 85698v.com | 3616t.com | www.996563.com | www.j32031.com | www.330067.com | js7.ch | 55977.com | www.lqc7.com | www.678js333.com | www.2229193.com | 7377.com | 2201885.com | www.809699.com | www.361148.com | www.tyc855.com | ss56988.com | 11555156.com | www.244689.com | www.0601e.com | www.20199kk.com | www.912399.com | 04666z.com | 3178p.com | www.fcyl2.com | www.44118s.com | www.ym777.cc | bm1397.com | sb83.com | bet365vip.com | www.152012.com | www.4156.com | www.bmw9968.com | www.laok111.com | 1104006.com | 2698s.com | www.689632.com | www.ejylc18.com | www.20199rr.com | www.76543p.com | 4647088.com | hg168f.com | g2490.com | www.66730.cc | www.44118j.com | www.80879.com | www.298345.com | 3650658.com | 28824t.com | www.89894w.com | www.2588cai.com | www.86339m.com | www.bm246.com | www.9068jj.com | 8290z.com | 01234ggcom | 0044886.com | www.401276.com | www.45258.cc | www.222335.com | www.rg666.com | www.4272000.com | 1156zz.com | 2490r.com | 4546.com | feicai0451.com | www.301823.com | www.107ak.com | www.957004.com | www.mgm868002.com | www.636123.com | www.00755.com | 5589921.com | 32008.com | pj8821.com | bbx888.com | www.150961.com | www.987325.com | www.99638d.com | www.12136n.com | www.8967r.com | www.c6784.com | www.yh66855.com | 21866n.com | rr00558.com | d2306.com | r61788.com | 2334.com | www.196067.com | www.897030.com | www.37124.com | www.954321j.com | www.69567x.com | www.4136i.com | www.1389mm.com | www.173msc.com | www.10054455.com | www.7009844.com | 2247c.com | 3651111111.com | xd2018.com | 876q.com | 863873.com | 7733vn77.com | 996622xx.com | yeba17.com | targe889q.net | www.505151.com | www.810527.com | www.5xct.com | www.9478r.com | www.89894z.com | www.yh75060.com | www.5552721.com | www.32031c.com | www.3983177.com | www.7415kk.com | www.56655c.com | www.3171114.com | www.59909.com | www.xpj2025.com | www.ld4488.com | www.6020200.com | www.s22365.com | www.2880880.com | www.7435r.com | www.514234.com | hgw168e.com | laohu88.vip | j58000.com | 11422z.com | mm56667.com | 9474.com | www.284888.com | www.bet056365.com | www.65533b.com | www.hg9222.com | www.532858.com | www.38200m.com | www.wnsr878.com | www.hg131.com | www.boma0111.com | www.10054455.com | www.330099f.com | www.k87087.com | www.566858.com | www.hg72999.com | www.911955.com | www.86778.com | www.2y930.com | www.wy8008.com | www.00772i.com | www.6880vv.com | www.g83377.com | www.36yl.com | www.35898.COM | www.b98478.com | www.68568f.com | www.5095g.com | www.c137.vip | www.585808.com | www.234269.com | 6601234.com | pj677l.com | zz5144.com | aobo77777.com | 492oo.com | sbc288.com | 70118n.com | 4433vn77.com | www.654bet.com | www.838383.com | www.3814.hk | www.90j.com | www.4196x.com | www.a201879.com | www.96386y.com | www.66clf.com | www.616971.com | www.118428.com | 35252w.com | pt7008.com | 3846w.com | 3045.com | www.pj5903.com | www.18933i.com | www.860389.com | www.4078n.com | www.9187o.com | www.80075j.com | www.c4530.com | www.178593.com | 51133hh.com | qiangui001.com | 80368d.com | amjsc01.com | www.7830o.com | www.973777.com | www.5981l.com | www.7225r.com | www.16065x.com | www.xcn6.com | www.015990.com | www.44gpc.com | www.633813.com | yh777.com | 56988cc.com | 6261nn.com | www.wns8.com | www.hg6651.com | www.hg8zz.com | www.6022888.com | www.am7979.com | 3685d.com | 88682.com | 86811t.com | www.88yh765.com | www.79900.com | www.60886f.com | www.26878t.com | www.347918.com | 52688g.com | 82365x.com | www.0882389.com | www.jh1188.com | www.88325f.com | www.33112.com | www.0377555.com | gg69096.com | xl15.net | www.777444d.com | www.c5c33.com | www.646869.com | www.01hfcp.com | 28747.com | 3559x.com | www.ao599.com | www.u75778.com | www.676711.com | www.c1350.com | 50020088.com | 4590vv.com | www.28758e.com | www.50000977.com | www.9192666.com | www.550154.com | 2021j.com | 2776f.com | www.279765.com | www.n1432.com | www.2934c.com | 69446611.com | 38365b.com | www.23426b.com | www.c44ii.com | www.820808.com | www.221836.com | 5000008059.com | 3544b.com | www.1828338.com | www.68070.com | www.342577.com | 871ww.com | 9539y.com | www.a01885.com | www.0601k.com | www.112669.com | 00jidu.com | www.060xpj.com | www.ybw18.com | www.32123t.com | 3033e.com | mm1915.com | www.330099e.com | www.574546.com | www.771745.com | 1634r.com | vnsr55888.com | www.pj5958.com | www.88266l.com | 2127ss.com | pj09595.com | www.3775799.com | www.562bbb.com | www.338031.com | 55331cc.com | www.alpk8.com | www.91779u.com | www.768997.com | 30007l.com | www.682855.com | www.9951331.com | www.915990.com | bwinvvv.com | www.85770b.com | www.7893.ag | www.670209.com | sbo333.com | www.7893900.com | www.44118n.com | www.375957.com | so55555.cc | www.hg9556.com | www.6678687.com | 79889t.com | 2757t.com | www.09848.com | www.9155f.com | sbd027.net | www.143800.com | www.huangma28.com | www.612212.com | xpj99909.com | www.4318q.com | www.10888.com | 4638877.com | c51ki64.com | www.9b800.com | www.815266.com | a7454.com | www.bd0088.com | www.js69z.cc | 1517726.com | 1168t.com | www.js69111.com | www.liuguan000.com | 00774ff.com | www.49522.com | www.005ac.com | 1213uuu.com | www.yh8352.com | www.bet73u.com | am56.cc | www.85770p.com | www.68365.com | vip.city78.cn | yinhewang.cc | www.357306.com | www.097079.com | 76886e.com | www.4212z.com | www.541711.com | 00882007.com | www.bsd9999.com | www.869619.com | lc99m.com | www.746778.com | www.c1393.com | sbd9.vip | www.d22365.com | www.788572.com | aipin11.me | www.9788t.com | www.621312.com | 11005l.com | www.288988b.com | www.338073.com | 00224002.com | www.4996sz.com | www.39500a.com | 5446hh.com | www.78680e.com | 074f7.com | www.537bet.com | www.hg6767a.com | 31786666.com | www.33189.com | www.8299.cc | 9679y.com | www.566652.com | www.313055.com | 500000794.com | www.834546.com | 36989g.com | www.hg2968.com | www.50052t.com | j1458.com | www.4399msc.com | www.440343.com | zhcp91.com | www.68365u.com | 66300vip06.com | www.v6558.com | www.bei01.com | aipin11.me | www.a69096.com | gg5443.com | www.h7788y.com | www.15237.cc | 2229gp.com | www.xpj556677.com | 3936z.com | www.2222wnsr.com | www.66621q.com | 8159v.cc | www.163a66.com | 5588336.com | www.yh5099.com | www.23636vip.com | 54146699.com | www.316088.com | 666vn77.com | www.7111p.com | www.616777a.com | l277.com | www.3775j.com | 2334vip8.com | www.sbtyc.com | 59964ww.com | www.mgm004.com | www.3933n.cc | 25288n.com | www.xpj6886.com | 222v22.com | www.rk1177.com | 8449cc.com | www.9996oo.com | www.c6881.com | 3434mmm.com | www.jsyl.cm | afcp10.com | www.958.net | 4270jj.com | www.3277msc.com | am2948.com | www.0860x.com | www.673066.com | 1168t.com | www.94238.com | 00uu8331.com | www.106a56.com | 93910.com | www.b35ii.com | dz888.com | www.lxyl360.com | 55145.com | www.89880033.com | www.477373.com | www.js80388.com | www.mody8.com | 5004sss.com | www.9356j.com |