Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 带in子句的nvl函数_Sql_Oracle_Nvl - Fatal编程技术网

Sql 带in子句的nvl函数

Sql 带in子句的nvl函数,sql,oracle,nvl,Sql,Oracle,Nvl,我的NVL函数有问题。我可以使用in子句properyl,但当我添加NVL时,它会给出错误 我的问题是这样的: SELECT ci.date, SUM (cid.salary) amount, SUM (cid.slary_gross) gross_amount FROM students ci, orders cid WHERE ci.id IN NVL((select id from sysadm.students where

我的NVL函数有问题。我可以使用in子句properyl,但当我添加NVL时,它会给出错误

我的问题是这样的:

SELECT  ci.date, 
 SUM (cid.salary) amount, SUM (cid.slary_gross) gross_amount
    FROM students ci,
         orders cid           
 WHERE 
 ci.id IN  NVL((select id from sysadm.students
 where status = 'IN' AND student_id= 24514 ORDER BY id
 FETCH FIRST 3 ROWS ONLY), ci.id ) 
我的错误:01427。00000-单行子查询返回多行

İ如果我删除了nvl函数,只需像下面这样写它正在运行。我如何使用nvl with in子句

从sysadm.students中选择id中的ci.id,其中status='IN'和student_id=24514 ORDER BY id仅获取前3行

我怀疑子查询中的id是否为空。因此,我建议:

with s3 as (
       select s.id
       from sysadm.students s.
       where s.status = 'IN' and s.student_id = 24514
       ORDER BY id
       FETCH FIRST 3 ROWS ONLY
      )
select . . .
where ci.id in (select id from s3) or
      not exists (select 1 from s3);
这将检查您的id是否在列表中,或者列表是否为空