在View中添加空白列 [英] Adding blank column in View

查看:58
本文介绍了在View中添加空白列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!



我有一个视图,我想添加一个新列。我正在创建这个视图,视图中的数据来自两个视图(tableA和tableB)。我们只说tableC是我的新观点。我希望在这个条件下我的tableC中的最后一列(column5):



对于TableC中的每个数据

如果TableA的column2< = TableB的column3然后tableC中的column3 = 1

否则tableC中的column3 = 0

每个结束



这可能吗?我可以创建一个新表。最后一栏应该是上述条件。



我是SQL的新手。通常做前端,所以我对SQL中的所有术语都是新的。

如果你们中的一些人可以提供帮助,我会很幸运。谢谢。



如果需要进一步的说明,可以在下面发表评论。

Hi!

I have a view which I want to add a new column. This view I am creating, the data in the view is from two views (tableA and tableB). Let's just say tableC is my new view. I want the last column(column5) in my tableC in this condition:

For each data in TableC
if column2 of TableA <= column3 of TableB then column3 in tableC = 1
else column3 in tableC = 0
End For Each

Could this be possible? It is okay for me to create a new table. Just the last column should be in that condition stated above.

I am a newbie in SQL. Usually doing front-end, so I am new with all the terms in SQL.
I will be so blessed if some of you can help. Thanks.

Feel free to comment below for further instructions.

推荐答案

请记住,没有经过测试。



Just out of mind, not tested.

SELECT 
    CASE WHEN TableA.Column2 <= TableB.Colum3 THEN 1 ELSE 0 END AS Column3
FROM Table A INNER JOIN TableB ON ................
WHERE...................






关注你的情况,试试下面的sql语句



Hi,

focusing on your condition, try below sql statement

CASE WHEN TABLEa.COL2 <= TABLEb.COL3 THEN TABLEc.COL3=1 ELSE  TABLEc.COL3=0 END





希望这会对你有所帮助。





干杯



Hope this will help you.


Cheers


这篇关于在View中添加空白列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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