大小写,如果在SQL 2005 [英] case and if in sql 2005
本文介绍了大小写,如果在SQL 2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我有一张桌子
Hello,
I have a table
slno Number Type
1 100 P
1 101 A
2 200 P
2 202 A
根据要求,我需要显示
As per the requirement i need to display
Police : 100
Ambulance:101
Emergency Police : 200
Emergency Ambulance: 202
任何人都可以解决此查询.
请帮帮我.
[edit]已添加代码块-OriginalGriff [/edit]
Any one can solve this query.
Please help me.
[edit]Code block added - OriginalGriff[/edit]
推荐答案
CASE Typer
当人数= 100时,警察:(rs!Number)
当人数= 101则救护车:(rs!Number)
...
ELSE ...
END
像这样的东西.
CASE Typer
WHEN Number = 100 THEN Police : (rs!Number)
WHEN Number = 101 THEN Ambulance : (rs!Number)
...
ELSE ...
END
something like that..
亲爱的朋友,
试试这个...
当slno = 1且Type =''P''时选择大小写,然后选择''Police:``+ Number
当slno = 1且Type =''A''时''Ambulance:''+ Number
当slno = 2且Type =''P''时''紧急警察:''+数字
当slno = 2且Type =''A''时''''紧急救护车:''+其他号码
your_Table
Dear Friend,
Try this...
Select case when slno=1 and Type=''P'' then ''Police : ''+Number
when slno=1 and Type=''A'' then ''Ambulance : ''+Number
when slno=2 and Type=''P'' then ''Emergency Police : ''+Number
when slno=2 and Type=''A'' then ''Emergency Ambulance : ''+Number else
''No Number Found'' end from your_Table
这篇关于大小写,如果在SQL 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文