查询中的修改结果 [英] modified result in query

查看:91
本文介绍了查询中的修改结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个看起来像这样的查询:

Hi all,

I have query that looks like this:

SELECT quantity FROM table



要选择的记录是整数,我想得出结果:
如果0-> 0件
如果1-> 1个
如果2-> 2个..等

请帮助我如何做到这一点.



the records to be selected are integers and i want to result:
if 0 --> 0 pc
if 1 --> 1 pc
if 2 --> 2 pcs.. etc

Help me how to do this pls. THanks in advance!!

推荐答案

通常,不应在SQL语句中进行格式化,而应在用户界面,报表等中进行格式化.在这种情况下,您可以考虑将格式代码移至调用方.
In general formatting shouldn''t be done in the SQL statements, but in the user interface, report etc. Without knowing anything more about the situation, you could consider moving the formatting code to the calling side.


尝试以下操作:

Try this one:

SELECT  quantity CASE
                   WHEN quantity = 0 OR quantity = 1 THEN quantity + ' pc'
                   WHEN quantity >= 2 THEN quantity + ' pcs'
                 END  



希望对您有帮助!

问候,
爱德华



Hope it helps!

Regards,
Eduard


这篇关于查询中的修改结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆