将多个选择语句添加到SQL中的表
我有2个单独的选择语句,我想在SQL的结果表中将它们添加为2个单独的列,以便我可以比较它们。他们俩都是从同一张桌子中选出的,所以我只是想知道如何处理。
select distinct(varA) from table1
where cond = '0.0000'
select distinct(varA) from table1
where cond > '0.0000'
order by varA
I have 2 separate select statements and I wanted to add them as 2 separate columns in the results table in SQL so I can compare them. They're both being selected from the same table so I just wanted to know how to go about it.
select distinct(varA) from table1
where cond = '0.0000'
select distinct(varA) from table1
where cond > '0.0000'
order by varA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,如果您的VARA值为“ A”,为什么您要使用A和A的两个列?您不想比较实际的“ cond”值?无论如何,下面的两个解决方案:
创建表和插入值:
查询如果只想返回vara值,这在我看来是完全无济于事的。如果您的DBM不支持通用表表达式,则将其更改为JOIN。
结果,似乎是无助的。
查询如果返回COND值,这更有意义,并假设这是您真正想要的。
结果:
So if your varA value is "A", why would you want two columns with A and A? Wouldn't you rather compare the actual "cond" values? Regardless, both solutions below:
Create table and insert values:
Query if wanting to return just the varA values, which is completely unhelpful in my opinion. If your DBMS does not support Common Table Expression, then change that to a join.
Results, again which are seemingly unhelpful.
Query if returning the COND values, which makes much more sense, and assume this is what you actually want.
Results: