我的选择语句上的自定义列
我还是 SQL (Oracle) 新手.. 基本上在我选择的表上,有一个时间戳,有些是有效的时间戳,有些不是(存储在时间戳表上)..我有一个可以在“where”子句中使用的函数来仅返回有效或无效的。
但有时我需要查看所有记录,并附加一个“有效”或“无效”列。我尝试过类似这样的案例;
select *, case when function(stamp)=1 then 'Valid' else 'Invalid'
但总是给我错误。我可能语法错误。谁能帮我解决这个问题吗?
I'm still new to SQL (Oracle)..
Basically on a table I'm selecting from, there is a time stamp, and some are valid stamps and some are not (stored on a time stamp table).. I have a function I can use in 'where' clauses to return only the valid or invalid ones.
But sometimes I need to see all the records with an additional column that says 'Valid' or 'Invalid'.. I tried cases, something like this;
select *, case when function(stamp)=1 then 'Valid' else 'Invalid'
but always gives me errors. I might be getting the syntax wrong. Can anyone help me figure this out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您错过了案例的结尾:
You're missing the END for the CASE:
尝试
分享并享受之类的事情。
Try something like
Share and enjoy.