<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.4988h.cc | 2427888.com | www.773456.com | www.c144.vip | 7744www.com | www.52062a.com | 55555004.com | www.226833.com | www.008ac.com | 73055w.com | www.lb55567.com | www.117318.com | D8.com | www.38775ss.com | 5504v.com | www.k973.com | www.648377.com | 22kk8332.com | www.g98478.com | 2222k95.com | www.pj990.com | www.630675.com | 6423j.com | www.30wb.top | 3559pp.com | www.5981h.com | 2677iii.com | www.3643o.com | www.66073.cc | 2078l.com | www.3116h.com | vns8y.com | www.hg281.com | www.401265.com | www.81866t.com | www.dayou566.com | 25228.am | www.vn888345.cc | 80567g.com | www.cp009x.com | 5003ll.com | www.xpj98k.com | www.506969.com | www.198488.com | www.15259.cc | 5005m.com | www.fh7577.com | biying900vip.com | www.0073.com | 88770.com | www.566493.com | f1915f.com | www.07679v.com | 3678uu.com | www.369410.com | v997e.com | www.7415gg.com | xpj04000.com | www.8828fh.com | 83377e.com | www.40789b.com | 88904141.com | www.123f4.com | 00074066.com | www.339879.com | 51335z.com | www.822898.com | 7172.us | www.88803.com | 76543c.com | www.942727.com | m88vn.com | www.hg6009.com | x33j.vip | www.810234.com | 90307b.com | www.sun7789.com | 3056.com | www.788jyh.com | 5622e.com | www.vns33.me | 87965hh.com | www.40wb.top | 168cp-l.com | www.29277r.com | hg85877.com | www.lczg2.com | www.w30226.com | www.299850.com | www.hg88.us | v93902.com | www.4866a90.com | xpj677h.com | www.4058ee.com | ii4255.com | www.866471.com | 3083.com | www.627797.com | www.43677.com | 83929.com | www.yfcp066.com | 013373.com | www.326213.com | 78365.com | www.9818z.cc | www.xpjdc.com | ibet888.net | www.5049s.com | 4165f.com | www.087r.com | xg9111.com | www.588824.com | www.40344.com | 86688003.com | www.60886u.com | 32689.com | www.80075.com | www.617704.com | df6258.com | www.751.cc | 0289f.com | www.3978r.com | 1168k.com | www.338996.com | www.caibb.com | bwin6804.net | www.78949g.com | www.88864400.com | 4647.net | www.9908598.com | 239239.com | www.1035z.com | www.497789.com | 3189bb.com | www.kelake55.com | www.1368s.cc | www.150168.com | www.55074.com | www.62979f.com | www.1851134.com | www.89677g.com | www.38345x.com | www.807239.com | www.10482.com | www.633786.com | www.76568.com | www.tm3721.com | www.98333.com | www.98333.com | www.46768.com | www.hg3875.com | www.tk48.com | www.tianbet.com | www.383188.com | www.65581.com | www.yf220.com | www.25000c.com | www.c1121.com | www.6766msc.com | www.2y930.com | www.5049k.com | www.1700116.com | www.38345j.com | www.sb5502.com | www.sha3111.com | www.js8888888830.com | www.47506a.com | www.ag4444.com | www.6880bb.com | www.5446b.com | www.984702.com | www.89777t.com | www.0270k.com | www.9928i.com | www.022q.cc | www.799481.com | www.598966.com | www.320055.com | www.80075i.com | 3301844.com | 2078n.com | 0201ff.com | 4066n.com | 7773805.com | 3458940.com | hkmh11.com | www.5487567.com | www.bl45.com | www.6372008.com | www.c44uu.com | www.3066bb.com | www.52062m.com | www.55268.vip | www.8667s.com | www.609815.com | www.171880.com | 50028833.com | 188qq888.com | 84497733.com | x48k.com | www.66318t.com | www.869msc.com | www.848777l.com | www.56011q.com | www.68568l.com | www.791361.com | red0035.com | w11.vip | 80892vv.com | xpj668.com | www.nbe666.com | www.dbyyh.com | www.47506h.com | www.77055.com | www.926576.com | www.099192.com | 2649mm.com | 888.vip | 30007f.com | www.67797d.com | www.8222000.com | www.91779c.com | www.574119.com | www.960201.com | 1483jj.com | 3467l.com | 1hga.com | www.88837a.com | www.e0437.com | www.d63568.com | www.3668p.com | www.50051v.com | 7894z.com | 70118JS.com | www.yh66855.com | www.cp67771.com | www.924924.com | www.78wcp.com | 48330N.com | 915310.com | blh2018.com | www.kelake22.com | www.40288j.com | www.8039f.com | www.053059.com | dsh3388.com | y99345.am | www.330099y.com | www.19019j.com | www.998855aa.com | www.296180.com | 93922u.com | 6245o.com | www.hg0204.com | www.79095w.com | www.022nx.cc | 8633001.com | 6150u.com | www.36787d.com | www.89894o.com | 228449.com | 9420k.com | www.0866.com | www.yh76b.com | www.43131r.com | spj555.com | www.4644444.com | www.2019.com | www.25688p.com | 46460524.com | 032526.com | www.868686.cc | www.69567l.com | www.860958.com | oo44442.com | cpcp.com | www.c46.com | www.31047.com | 2546u.com | 80850ii.com | www.699a.cc | www.bb888.cc | 22234066.com | 4052p.com | www.788078.com | www.hg6833.com | www.394511.com | 1422.cc | www.10052233.com | www.598888.vip | www.283550.com | 4461x.com | www.4972hh.com | www.xyh6002.com | www.393477.com | 888559.com | www.9996ff.com | www.38775pp.com | www.346177.com | 4255jjj.com | www.vns78999.com | www.4323z.com | 249163.com | 55qq8332.com | www.365066.bet | www.qbwc7.com | blr365365.com | www.76060k.com | www.33678dd.com | www.368158.com | 3534i.com | www.msc51.com | www.7714f.com | 6868003.cc | 496.ma | www.cn365m.com | www.567306.com | 4340j.com | www.67894.com | www.20016.cc | 28288f.com | www.55268rr.com | www.6888773.com | mgm3242y.com | 79889b.com | www.l3410.com | www.025727.com | 2007570.com | www.79500v.com | www.775710.com | 93922w.com | www.zz00y.com | www.0014q.com | 2709x.com | www.226833.com | www.52303z.com | 1407j.com | www.h7788q.com | www.68203g.com | 8betbet365.com | www.808xpj.com | www.97365.com | 28839i.com | www.ylg05.com | www.28891e.com | 2229jgj.com | www.yhuuu.com | www.xb99aa.com | 3678w.com | www.333133r.com | www.50633.com | 9068bb.com | www.amxhtd11.com | www.8jcw.com | ff3336.com | www.cbvip.com | www.594911.com | am8888.net | www.38138a.com | 11992007.com | www.0636g.com | www.7714o.com | ls887.com | www.xg189.net | www.933509.com | 22aa8332.com | www.55070i.com | 22296ai.com | www.hg45888.com | www.59899a.com | js6444.com | www.500994.com | www.636121.com | 55331o.com | www.417920.com | 3169c.com | www.0805u.com | www.gy11.com | 61828.biz | www.8855gvb.com | 52688k.com | www.661990.com | www.574377.com | 500000701.com | www.pj99m.com | 3122s.com | www.hd779.com | www.xinyc2.com | www.pu5555.net | www.52072h.com | pj88dd.com | www.4058i.com | 1489y.com | www.am1818.cc | www.602891.com | 6hcc77.com | www.6664588.com | 566777t.com | www.848777t.com | yth18.net | www.449941.com | www.551549.com | www.81866c.com | www.50732x.com | 838388b.com | www.8905e.com | i86811.com | www.987071.com | bf5988.com | www.b2229b.com | www.239838.com | www.32126v.net | www.hf6680.com | 537.cc | www.97655p.com | pj00oo.com | www.6688kcd.com | 3333744.com | www.55070r.com | 3559qq.com | www.201081.com | JS1388w.com | www.84299.com | www.257233.com | www.87680x.com | www.612918.com | www.7652.cc | www.853530.com | www.dz825.com | www.en06.com | www.892558.com | www.932779.com | www.hg45888.com | www.842223.com | www.7435c.com | www.785579.com | www.7337942.com | www.560681.com | www.9068bb.com | www.325771.com | www.3844f.com | www.87668v.com | www.amdc55.com | ttdl4008123.com | www.www899000.com | bet365vip.com | www.5966vvv.com | c46.cc | www.9170106.com | 35ww.vip | www.7240e.com | 6137o.com | www.dfw993.com | am2828.cc | www.666hy.cc | www.32126e.net | www.0586777.com | www.bmw8555.com | 56988d.com | www.dfh271.com | 93922k.com | www.ddd2848.com | 9879733.com | www.96386y.com | ff5443.com | www.743633.com | www.330099d.com | xpj377c.com | www.79500h.com | 1463v.com | www.778305.com | 7788xpj.com | www.757q.com | www.hg2328.com | 6601234.com | www.jy959.com | shibolianmen.com | www.hg810.com | feicai0734.com | www.731030.com | www.84162222.com | 5906vv.com | www.1559506.com | 91019u.net | www.3008553.com | 5856rr.com | www.22630.cc | www.2090933.com | 12124688.com | www.58665h.com | 0234nn.com | www.77016.net | 99992007.com | www.igcp4.com | www.88837r.com | 8742gg.com | www.4996yx.com | jjj4165.com | www.99677d.com | www.ks299.com | q759.top | www.hg8nn.com | 5856rr.com | www.910xj.com | www.hg2282.com | ks3338.com | www.252018.com | 923130.com | www.595301.com | www.681122.com | 0241s.com | www.pj56c.com | www.266688.com | 186568.com | www.30350m.com | 500000419.com | www.949498.com | www.01389.com | bh55654.com | www.56588.com | www.777444c.com | 4066bb.com | www.1033.app | www.35066.com | yongligao.cc | www.69567p.com | dzj.am | 1213iii.com | www.j7764.com | bb8888.com | www.89894e.com | www.mhcp1.com | 22qq8331.com | www.506729.com | www.sj52488.com | yl6896.com | www.809296.com | www.a9151e.com | zd6161.com | www.6fk.com | www.wp9977.com | 6261m.com | www.989841.com | www.25xz.com | 86611l.com | www.900845.com | www.597567d.com | 4242hd.com | www.506232.com | www.6668ylg.com | y854.cc | www.186753.com | www.578371.com | ysb8.com | 2690js.com | www.725641.com | www.2899msc.com | dzj.tw | www.hy5509.com | www.y948y.com | j99345.am | www.238500.com | www.028126.com | 4631177.com | 88850pp.com | www.84499r.com | www.10ff8.com | 316960.com | www.618477.com | www.v69096.com | 20771166.com | 500000631.com | www.7116c.com | www.577444.com | ca9033.com | 54141144.com | www.2418o.com | www.01678cp.com | 4036222.com | www.312180.com | www.006786.com | www.333222v.com | 1434p.com | www.c229.vip | www.00773x.com | 7736j.com | 32355aa.com | www.1176.cc | www.5099ss.com | 39520.net | ll1915.com | www.cp718.com | www.77731c.com | lewen123.com | hg0088.pw | www.815266.com | www.9570119.com | www.hg77719.com | 2172226.com | www.77dwj.com | www.4136r.com | www.0011hg.com | 060ccc.com | www.317299.com | www.975277.com | www.08922004.com | 53262c.com | 0363d.com | www.36788g.com | www.27363a.com | www.dz578.com | 7686l.com | www.206883.com | www.6889792.com | www.8804567.com | ying58.xyz | yh55.com | www.890992.com | www.742688.com | www.8888888b.com | 588mmm.cc | 88463gong.com | www.5441q.com | www.35252d.com | www.i7727.cc | 86811o.com | 5651a.com | www.564658.com | www.hg77740.com | www.3122mm.com | 5003zzz.com | y8381.com | www.50788u.com | www.50026j.com | www.839797.com | www.009suncity.com | 8666.hk | 78111199.com | www.178615.com | www.89894z.com | www.DF83.com | www.h30226.com | 3640.vip | z88ww.com | www.526733.com | www.yh7773.com | www.97060h.com | www.9679900.com | 9339999n.com | 1665jj.com | www.55djcp.com | www.0343p.com | www.120509.com | www.8694y.com | 3002535.com | 5002sss.com | 4379i.com | www.qbwc4.com | www.00797c.com | www.ggu.99233u.com | www.un5533.com | 634006.com | mm90856.com | www.570126.com | www.5856886.com | www.4963hh.com | www.dd7920.com | 1483hh.com | 3788d.com | xx888v.com | 496.be | www.799100.com | www.7714e.com | www.63606w.com | www.hg7688.com | www.9996vv.com | 888p1.cc | 287722.com | 6699vn77.com | www.192762.com | www.c2808.com | www.633594.com | www.820013.com | www.s4042.com | www.143vns.com | www.4759pp.com | 9995w.cc | 35222dd.com | j2489.com | 3178g.com | baidu886.com | www.760557.com | www.29699.com | www.48330e.com | www.673888h.com | www.27038.com | www.x6099.com | 6220z.com | 463a8.com | 3mgmjbp.com | bet28u.com | www.217302.com | www.ascp5.com | www.29277y.com | www.ag99365.com | www.173151.com | www.2392.com | www.015kj.com | www.25288j.com | www.8xinhao.com | 272nn.net | ff2205.com | 61326666.com | a70333.com | f58955.com | 8898222.com | 838388a.com | 1104028.com | 1429w.com | 500000335.com | www.43131m.com | www.327988.com | www.870300.com | www.hcjt3.com | www.36788w.com | www.83033k.com | www.4331vip.com | www.tai3366.com | www.5886nn.com | www.ag3355.com | www.9931331.com | www.9737aa.me | www.58665d.com | www.yc7777.com | www.3033b.com | www.v56789.com | www.822822.com | www.pj7991.com | www.9996ll.com | www.vns71999.com | www.yddc666.com | 5002rrr.com | 1077sss.com | 5443r.com | 518cp1.com | 7200126.com | z2824.com | 5504g.com | 3009z.com | 6245.bet | huc288.com | www.dz578.com | www.yh66606.com | www.333177.com | www.sun008.cc | www.g83138.com | www.00618z.com | www.xpj9985.com | www.1590mm.com | www.amdc0007.com | www.15048u.com | www.063259.com | www.bd2019f.com | www.biying950vip.com | www.4196m.com | www.xpj3133.net | www.ra7909.com | www.6482c.com | www.83993w.com | www.5854j.cc | www.c3714.com | www.544010.com | www.399150.com | 3556vip7.com | 88447.com | 1458r.com | 1479o.com | 2146p.com | kkk01234.com | 838388y.com | 30006q.com | www.pj4666.com | www.77537q.com | www.729666.com | www.5966eee.com | www.00773a.com | www.r999994.com | www.82439.com | www.5854t.cc | www.771645.com | www.068619.com | 90307h.com | pjneimenggu.com | hg0088.tech | FuXingCai.com | 33432h.com | www.81866j.com | www.v6866.com | www.143vns.com | www.c44nn.com | www.519862.com | www.16065d.com | www.6364v.com | www.530126.com | 3685v.com | 1634r.com | i1458.com | 0025i.com | www.81866j.com | www.903253.com | www.ca338.com | www.04567d.com | www.1466l.com | www.2632h.com | www.308680.com | 3822v.com | 5360p.com | 71017g.com | www.yinhecc44.com | www.xj4466.com | www.ii55826.com | www.52062q.com | www.07163p.com | www.420689.com | k1.z6528.com | 0008ee.com | 55ii8332.com | www.995f.net | www.tyc788.com | www.pjh.com | www.99677m.com | www.599505.com | 79964a.com | 55309.com | vip1524.com | www.54541100.com | www.306015.me | www.vns998.me | www.8970.com | www.310657.com | 61828.info | bh889933.com | 2677yyy.com | www.7392022.com | www.bwinyz01.com | www.66652c.com | www.536411.com | kj5568.com | hjdzjgj.com | www.6033c.com | www.88233.com | www.ddd2848.com | www.9lbc.com | 66648x.com | 4488c.com | 51335u.com | www.79tyc.com | www.91779h.com | www.9205e.com | gemevog.com | 1813dd.com | 44335003.com | www.31399bb.com | www.77784yh.com | www.9149g.com | bwin8a.com | m08199.com | www.81866g.com | www.hg032.com | www.0077psb.com | www.890732.com | 2934d.com | ylzz2225.com | www.804suncity.com | www.9737vv.me | www.8667j.com | www.32123d.com | 8037q.com | www.vns994.cc | www.bfcaip.com | www.50080w.com | 66300vip16.com | 4590y.com | www.63877w.com | www.38345f.com | www.8039o.com | 5443yy.com | 33382ss.com | www.a27229.com | www.06387766.com | www.902271.com | wot.kongzhong.com | 2851n.com | www.877568.com | www.311999.cc | www.310477.com | 5504q.com | www.vns7730.com | www.w32939.com | www.48wcp.com | aa3336.com | vns345777.com | www.60339.com | www.9646z.com | 8333.org | 76886j.com | www.0139.com | www.3404.cc | www.60123u.com | 66136j.com | www.wns08888.com | www.4809s.com | www.178215.com | 3846ccc.com | www.84898v.com | www.79095l.com | www.595707.com | 463y8.com | www.7025i.com | www.7920m.com | www.210755.com | pj00xx.com | www.hg55328.com | www.63606e.com | www.313055.com | xx01234.com | www.bmw8555.com | www.3978v.com | 1479p.com | 5589b.com | www.987071.com | www.055e.cc | 4255ggg.com | www.28758l.com | www.3032ee.com | www.097968.com | 3559mmmm.com | www.jh1188.com | www.66870.cc | 22412.com | www.www-866766.com | www.848777e.com | www.540477.com | hga088.rs | www.xg808.cc | www.3416p.com | vns900.net | www.32126c.net | www.3775a.com | www.50064i.com | 0033u.cc | www.89599g.com | www.602857.com | 2ub.com | www.6699ok.com | www.26299x.com | zz01234.com | www.y6889.com | www.36584444.com | ahg5588.com | www.183ks.com | www.hg8.vip | man984.com | www.033033e.com | www.5446bb.com | 8464999.com | 6692.am | www.89386a.com | www.390706.com | 2jsfff.com | www.55070y.com | www.592771.com | t8381.com | www.472709.com | www.209713.com | 7141rr.com | www.n80288.com | www.178761.com | 4023n.com | www.7334b.com | www.354977.com | 8577j.cc | www.668cp22.com | www.315016.com | 500000316.com | www.wnsr3536.com | ceeger.com | 6175n.com | www.285628.com | bbb2267.com | www.3643v.com | www.65707b.com | 55957k.com | www.838080.com | www.662182.com | mg437766.com | www.j83377.com | 500000439.com | www.yh8210.com | www.60123g.com | 81366i.com | www.76773.com | www.319826.com | 50000944.com | www.36yl.com | 9895l.com | www.3332558.com | www.12455r.com | s77304.com | www.295111.com | www.444627.com | bet28w.com | www.6687n.com | 3122y.com | www.773114.com | www.9478w.com | 566777.com | www.8967d.com | www.26878a.com | www.892558.com | www.53900m.com | 5856ee.com | www.j32939.com | 2546z.com | www.33928a09.com | www.16588t.com | 38820011.com | www.9570118.com | 1665s.com | www.36607a.com | www.806726.com | feicai0457.com | www.55545k.com | 876878a.com | www.3029.com | www.34788i.com | 55899z.com | www.169082.com | 36402244.com | www.7415a.com | 1665456.com | www.xhtd05.com | www.918361.com | 37570a.com | www.1206.com | 01234r.com | www.rycp052.com | 7196ee.com | www.yxlmwx.net | www.810877.com | 69990e.com | www.50732q.com | 8040hhh.com | www.bwinyz03.com | vgjnk781jh.com | www.22448.com | www.186372.com | www.98599.com | www.929533.com | 28758c.com | www.50026r.com | xl15.net | www.938690.com | 3049c.com | www.10999k.com | 4022o.com | www.1488msc.com | qycp01.com | www.hg2631.com | www.160951.com | www.8814e4.com | www.399140.com | www.7435z.com | www.c8714.com | 118888p.com | www.39cp.cc | 2649dd.com | www.5484b.com | 8827kk.com | www.3890c.com |