| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> mssql >> SQL Server COALESCE() han shu de chuang xin ying yong
 

SQL Server COALESCE() han shu de chuang xin ying yong

2008-08-20 08:08:00 编辑來源:互联网 评论
 
本文为【SQL Server COALESCE()函数的创新应用】的拼音翻译版
  COALESCE() han shu ke yi jie shou yi xi lie de zhi , ru guo lie biao zhong suo you xiang dou wei kong (null), na me zhi shi yong yi ge zhi 。 ran hou , ta jiang fan hui di yi ge fei kong zhi 。 zhe yi ji qiao miao shu le chuang zao xing shi yong SQL Server zhong COALESCE() han shu de liang zhong fang fa 。
  zhe li you yi ge jian dan de li zi : you yi ge Persons shu ju biao , ta you san ge zi duan FirstName、MiddleName he LastName。 biao zhong bao han yi xia zhi :
  John A. MacDonald
  Franklin D. Roosevelt
  Madonna
  Cher
  Mary Weilage
  ru guo ni xiang yong yi ge zi fu chuan lie chu ta men de quan ming , xia mian gei chu le ru he shi yong COALESCE() han shu wan cheng ci gong neng :
  SELECT FirstName + '' '' +COALESCE(MiddleName,'''')+ '' '' +COALESCE(LastName,'''')
  ru guo ni bu xiang mei ge cha xun dou zhe yang xie , lie biao A xian shi le ru he jiang ta zhuan huan cheng yi ge han shu 。 zhe yang dang ni xu yao shi yong zhe ge jiao ben de shi hou ( bu guan mei ge lie de shi ji zhi shi shen me ), ke yi zhi jie tiao yong gai han shu bing chuan di san ge zi duan shen shu 。 zai xia mian de li zi zhong , wo chuan di gei han shu de shen shu shi ren ming , dan shi ni ke yi yong zi duan ming ti dai de dao tong yang de jie guo :
  SELECT dbo.WholeName(''James'',NULL,''Bond'')
  UNION
  SELECT dbo.WholeName(''Cher'',NULL,NULL)
  UNION
  SELECT dbo.WholeName(''John'',''F.'',''Kennedy'')
  ce shi jie guo ru xia :
  James Bond
  Cher
  John F. Kennedy
  ni ke neng hui zhu yi dao wo men de yi ge wen ti , zai James Bond zhe ge ming zi zhong you liang ge kong ge 。 tong guo xiu gai @result zhe yi xing ke yi gai zheng zhe ge wen ti , ru xia suo shi :
  SELECT @Result = LTRIM(@first + '' '' + COALESCE(@middle,'''') + '' '') + COALESCE(@last,'''')
  xia mian shi COALESCE() han shu de ling yi ge ying yong 。 zai ben li zhong , wo men jiang xian shi yi ge zhi fu gei yuan gong de gong zi dan 。 wen ti shi dui yu bu tong de yuan gong gong zi biao zhun shi bu tong de ( li ru , you xie yuan gong shi an xiao shi zhi fu , an gong zuo liang mei zhou fa yi ci gong zi huo shi an ze ren zhi fu )。 lie biao B zhong shi chuang jian yi ge yang biao de dai ma 。 xia mian shi yi xie shi li ji lu , mei ge shi yi zhong lei xing :
  1 18.00 40 NULL NULL NULL NULL
  2 NULL NULL 4.00 400 NULL NULL
  3 NULL NULL NULL NULL 800.00 NULL
  4 NULL NULL NULL NULL 500.00 600
  yong xia mian de dai ma zai tong yi lie zhong lie chu zhi fu gei yuan gong de zong e ( bu guan ta men de zhi fu biao zhun ):
  SELECT
  EmployeeID,
  COALESCE(HourlyWage * HoursPerWeek,0)+
  COALESCE(AmountPerPiece * PiecesThisWeek,0)+
  COALESCE(WeeklySalary + CommissionThisWeek,0)AS Payment
  FROM [Coalesce_Demo].[PayDay]
  jie guo ru xia :
  EmployeeID Payment
  1 720.00
  2 1600.00
  3 800.00
  4 1100.00
  ni ke neng xu yao zai ying yong cheng xu zhong duo chu shi yong zhe yi ji suan fang fa , sui ran zhe zhong biao shi ke yi wan cheng ren wu , dan shi kan qi lai bu shi hen mei guan 。 xia mian lie chu le ru he shi yong yi ge dan du de qiu he lie lai wan cheng zhe xiang gong zuo :
  ALTERTABLE Coalesce_Demo.PayDay
  ADD Payment AS
  COALESCE(HourlyWage * HoursPerWeek,0)+
  COALESCE(AmountPerPiece * PiecesThisWeek,0)+
  COALESCE(WeeklySalary + CommissionThisWeek,0)
  zhe yang zhi yao shi yong SELECT * jiu ke yi xian shi yu xian ji suan hao de jie guo 。
  xiao jie
  ben wen jie shao le shi yong COALESCE() han shu yi xie te shu chang he he te shu fang shi 。 jiu wo de jing yan kan lai ,COALESCE() han shu zui chang chu xian zai yi ge ju ti de nei rong zhong , ru yi ge cha xun huo shi tu huo cun chu guo cheng zhong 。
  ni ke yi jiang COALESCE() fang zai yi ge han shu zhong lai shi yong ta , ye ke yi tong guo jiang ta fang zai yi ge dan du de ji suan lie zhong you hua xing neng , bing zong neng huo de jie guo 。【原文】【汉音对照
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
COALESCE() han shu ke yi jie shou yi xi lie de zhi , ru guo lie biao zhong suo you xiang dou wei kong (null), na me zhi shi yong yi ge zhi 。 ran hou , ta jiang fan hui di yi ge fei kong zhi 。 zhe yi ji qiao miao shu le chuang zao xing shi yong SQL Server zhong COALESCE() han shu de liang zhong fang fa 。 zhe li you yi ge jian dan de li zi : you yi ge Persons shu ju biao , ta you san ge zi duan FirstName、MiddleName he LastName。 biao zhong bao han yi xia zhi : John A. MacDonald Franklin D. Roosevelt Madonna Cher Mary Weilage ru guo ni xiang yong yi ge zi fu chuan lie chu ta men de quan ming , xia mian gei chu le ru he shi yong COALESCE() han shu wan cheng ci gong neng : SELECT FirstName + '' '' +COALESCE(MiddleName,'''')+ '' '' +COALESCE(LastName,'''') ru guo ni bu xiang mei ge cha xun dou zhe yang xie , lie biao A xian shi le ru he jiang ta zhuan huan cheng yi ge han shu 。 zhe yang dang ni xu yao shi yong zhe ge jiao ben de shi hou ( bu guan mei ge lie de shi ji zhi shi shen me ), ke yi zhi jie tiao yong gai han shu bing chuan di san ge zi duan shen shu 。 zai xia mian de li zi zhong , wo chuan di gei han shu de shen shu shi ren ming , dan shi ni ke yi yong zi duan ming ti dai de dao tong yang de jie guo : SELECT dbo.WholeName(''James'',NULL,''Bond'') UNION SELECT dbo.WholeName(''Cher'',NULL,NULL) UNION SELECT dbo.WholeName(''John'',''F.'',''Kennedy'') ce shi jie guo ru xia : James Bond Cher John F. Kennedy ni ke neng hui zhu yi dao wo men de yi ge wen ti , zai James Bond zhe ge ming zi zhong you liang ge kong ge 。 tong guo xiu gai @result zhe yi xing ke yi gai zheng zhe ge wen ti , ru xia suo shi : SELECT @Result = LTRIM(@first + '' '' + COALESCE(@middle,'''') + '' '') + COALESCE(@last,'''') xia mian shi COALESCE() han shu de ling yi ge ying yong 。 zai ben li zhong , wo men jiang xian shi yi ge zhi fu gei yuan gong de gong zi dan 。 wen ti shi dui yu bu tong de yuan gong gong zi biao zhun shi bu tong de ( li ru , you xie yuan gong shi an xiao shi zhi fu , an gong zuo liang mei zhou fa yi ci gong zi huo shi an ze ren zhi fu )。 lie biao B zhong shi chuang jian yi ge yang biao de dai ma 。 xia mian shi yi xie shi li ji lu , mei ge shi yi zhong lei xing : 1 18.00 40 NULL NULL NULL NULL 2 NULL NULL 4.00 400 NULL NULL 3 NULL NULL NULL NULL 800.00 NULL 4 NULL NULL NULL NULL 500.00 600 yong xia mian de dai ma zai tong yi lie zhong lie chu zhi fu gei yuan gong de zong e ( bu guan ta men de zhi fu biao zhun ): SELECT EmployeeID, COALESCE(HourlyWage * HoursPerWeek,0)+ COALESCE(AmountPerPiece * PiecesThisWeek,0)+ COALESCE(WeeklySalary + CommissionThisWeek,0)AS Payment FROM [Coalesce_Demo].[PayDay] jie guo ru xia : EmployeeID Payment 1 720.00 2 1600.00 3 800.00 4 1100.00 ni ke neng xu yao zai ying yong cheng xu zhong duo chu shi yong zhe yi ji suan fang fa , sui ran zhe zhong biao shi ke yi wan cheng ren wu , dan shi kan qi lai bu shi hen mei guan 。 xia mian lie chu le ru he shi yong yi ge dan du de qiu he lie lai wan cheng zhe xiang gong zuo : ALTERTABLE Coalesce_Demo.PayDay ADD Payment AS COALESCE(HourlyWage * HoursPerWeek,0)+ COALESCE(AmountPerPiece * PiecesThisWeek,0)+ COALESCE(WeeklySalary + CommissionThisWeek,0) zhe yang zhi yao shi yong SELECT * jiu ke yi xian shi yu xian ji suan hao de jie guo 。 xiao jie ben wen jie shao le shi yong COALESCE() han shu yi xie te shu chang he he te shu fang shi 。 jiu wo de jing yan kan lai ,COALESCE() han shu zui chang chu xian zai yi ge ju ti de nei rong zhong , ru yi ge cha xun huo shi tu huo cun chu guo cheng zhong 。 ni ke yi jiang COALESCE() fang zai yi ge han shu zhong lai shi yong ta , ye ke yi tong guo jiang ta fang zai yi ge dan du de ji suan lie zhong you hua xing neng , bing zong neng huo de jie guo 。
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
可爱车模崔星儿(17)
可爱车模崔星儿(16)
可爱车模崔星儿(15)
可爱车模崔星儿(14)
艳丽的海棠花
钓者
南半球的天空--天涯海角
雪之界
 
>>返回首页<<
 为你推荐
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
©2005- 王朝网络 版权所有