问题标签 [nvl]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1782 浏览

sql - 没有记录时显示列值为 0 的记录

我有以下表格:

在此处输入图像描述

架构

tbl_semester_empid {id,semester_name varchar(50),start_date}

tbl_batch_empid {id,term_id,batch_name,session_room}

tbl_associate_empid {id, associate_name,batch_id,联系,join_date,induction_result,stream_result int}

问题查询是:显示学期明智的员工人数。

我写了 3 个查询:

它们都显示以下输出(它只显示对应于其中至少有 1 个学生的那些学期的记录,如果该学期没有学生,则不显示该学期的信息):

在此处输入图像描述

我希望在 Associates Count 列中没有员工的学期为 0。所以我用两个 LEFT OUTE JOIN 尝试了同样的方法:

然而结果很奇怪:

在此处输入图像描述

0 投票
4 回答
386 浏览

oracle - 如果特定值的数据不存在,Oracle 查询以显示一些模板消息?

我想为表格中不存在的值显示一些模板消息。

示例

在上面给定的 4 个表中,只有EMPLOYEE表在那里,所以我想不显示其他结果的值,而不是不显示任何值。

我为此尝试了 nvl

但结果仍然没有到来

有什么建议可以得到结果..?

在此先感谢,请原谅我在 DB 中的任何错误

0 投票
1 回答
5674 浏览

oracle - Oracle:是否可以准确地连接来自两个不同表的空字段?

我有四个字段——itemnum、storeloc、binnum 和数量。

我正在尝试选择前三个字段匹配的数据,但 binnum 有时为空。当我对数量进行求和时,由于 NULL binnum,计算不正确。数据库有一个索引,其中只能有一个 itemnum、storeloc 和 binnum 组合,其中 binnum 可以为 NULL。我意识到允许密钥具有 NULL 数据是不好的做法,但我无法控制数据的结构。

我尝试了以下 where 子句:

两者都不起作用。有什么建议么?

0 投票
3 回答
14905 浏览

sql - SQL substituting NULL using NVL, having problems checking substituted value in the where clause correctly

I am running a query to display messages when the from date is before (<=) the current date and to_date is after (>) the current date.

If the to_date is NULL, then i give it a value using the NVL method and make the check n the where clause, and if it is not null - ie the user has provided the value for it - then it should use that value and check the condition in the where clause.

However when I do run this query for my database, I only get the results for when the user has entered a to_date. I DO NOT get results when to_date is null and it has the value '9999-12-31 23:59:59' - i.e.: It fails the a.to_date > current condition in the where clause and so does not return those entries. The value when to_date is NULL is substituted correctly with '9999-12 ...' but the where condition '> current' fails.

I want to make the substitution within the query and not as a seperate statement. Logically I think it should work but for some reason I am going wrong somewhere . Also not sure if this effects the query execution but the default value of to_date is set to NULL when creating the table.

Can you please help me with this issue. Thanks

0 投票
3 回答
32158 浏览

oracle - NVL 中的选择语句

我正在尝试运行以下查询:

我检查了一下,nvl 中的选择只返回 1 个值(所以那里不应该有问题)。但是我得到'ORA-00936:缺少表达'

0 投票
2 回答
1721 浏览

sql - 当 count(*) 不匹配任何记录时需要查询返回零

如果特定日期没有记录,我需要上述查询返回计数 0。这似乎没有发生。

我试过NVL,解码。发现问题是由于 group by 子句,但不知道如何解决这个问题。

请帮忙 !!

0 投票
2 回答
494 浏览

sql - SQL,显示字符串而不是 NULL/实际值

我正在处理一项任务,但遇到了这个问题:

*显示部门名称和所有员工的姓名以及他们的经理状态。状态应该为那些是经理的人显示消息“是经理”。对于那些不是经理的人,请显示“不是经理”的信息。还包括空部门,其中状态值应为“还没有经理”<br> 首先显示那些是经理的人,然后是那些不是经理的人,最后是空部门。在这些分组中,按员工姓名的字母顺序排序。这是标题示例。

部门名称 员工经理状态*

我知道 NVL 可以用来解释空值,但是这个问题让我很困惑。

与此问题相关的表格是:

雇员:

部门:

描述部门

如果有人可以给我一个提示,我可以使用哪个函数来显示字符串,而不是值,我会非常感激!

0 投票
1 回答
440 浏览

sql - 需要使用 nvl 函数从表中查询数据

我有一个有多个列的表。比如说,列是 C1、C2、C3 和 C4。

现在我需要以这样一种方式查询数据,即对于白天,应返回 C3 中对应于 a.C4 的值。如果 C3 没有 a.C4 的值,它应该在 C3 中为 b.C4 提供值。

0 投票
1 回答
1828 浏览

hibernate - 休眠 + nvl()= 甲骨文 01465

尝试执行使用空参数值的本机 SQL 查询时出现 Oracle 错误。我把它归结为这个测试用例:

该查询使用 Oracle 的NVL函数来处理null参数。q.getResultList ()但是,当我运行此代码时,它会因调用错误而失败。

错误如下:

现在,我解决了这个问题

但是这个解决方案并不好。

数据库 Oracle 11gR2 win1251 编码。

Netbeans 7.3.1 项目编码 UTF-8。

entity.getSvhlick() - Oracle 中的字符串 svhlick - varchar2(1)

我认为问题可能是由于编码不同。

有什么帮助吗?

0 投票
1 回答
177 浏览

oracle - Oracle 未按预期评估 nvl

此查询返回 colA 为空的行:

但是这个查询不 -

知道为什么第二个查询没有返回任何结果吗?