在Oracle中仅选择没有空值的列 [英] Select only Columns without Null values in Oracle

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

问题描述

我的桌子上有20列....

I have 20 columns in my table....

如何只选择没有空值的列

How can I select only columns that don't have null value

col1 col2 col3
20    12   null

所需的输出

col1 col2 
20    12  

推荐答案

SQL的语义不允许这样做-每个SQL查询都包含一个投影,您可以通过该投影指定要在输出中指定的列.

The semantics of SQL don't allow this - every SQL query includes a projection, by which you specify what columns you want in the output.

除非您两次运行查询,否则您将无法提前知道结果是什么.实际上,即使您两次运行查询,结果之间也可能会发生变化(除非您以可序列化模式运行它).

Unless you run the query twice, you can't know ahead of time what the results will be. In fact, even if you run the query twice, the results may change in between (unless you run it in serializable mode).

换句话说,这个问题没有多大意义.

In other words, the question doesn't make a lot of sense.

另一方面,如果您的要求是仅在向用户显示时隐藏该列,则这是一个完全不同的问题-该问题的答案不在于SQL,而在于您的表示逻辑.

On the other hand, if your requirement is to simply hide the column when displayed to the user, that's an entirely different question - one for which the answer does not lie in SQL, but in your presentation logic.

这篇关于在Oracle中仅选择没有空值的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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