Select a.recorded_hours,
and (((a.employee_hours+b.Quantity)/( ('&To_date' - '&from_date')*24))
From table1 a, table2 b
Where a.code=b.code
and a.site = b.site
and a.reg_date between '&from_date' and '&to_date'
with Parms as (
select '&from_date' as FROM_DATE, '&To_date' as TO_DATE from DUAL
)
Select a.recorded_hours,
(( (a.employee_hours+b.Quantity) / ((P.TO_DATE - P.FROM_DATE)*24)))
From table1 a
inner join
table2 b
on a.code=b.code
and a.site = b.site
inner join
Parms P
on a.reg_date between P.FROM_DATE and P.TO_DATE
-- This will ask you to enter parameter twice:
Select SubStr('ABCDEFGHI', &Pos, 1) || SubStr('123456789', &Pos, 1) "CELL" From Dual;
-- ... and this just once
Select SubStr('ABCDEFGHI', &&Pos, 1) || SubStr('123456789', &&Pos, 1) "CELL" From Dual;
SELECT a.recorded_hours,
((a.employee_hours + b.Quantity) / (('&&To_date' - '&&from_date') * 24))
FROM table1 a, table2 b
WHERE a.code = b.code
AND a.site = b.site
AND a.reg_date BETWEEN '&&from_date' AND '&&to_date';
字符串 怎么做?像这样:
SQL> select '&&par_name' from dual where '&&par_name' = 'ABC';
Enter value for par_name: ABC
'AB
---
ABC
3条答案
按热度按时间vd2z7a6w1#
您可以在CTE(
WITH ... as
)中从DUAL接收参数到单行中,并将该表连接到您的查询:字符串
我还将表a和b的连接语法更改为更现代的
INNER JOIN
语法。3npbholx2#
只需将&字符重复两次:
字符串
结果是一样的:
型
yptwkmov3#
使用两个号代替:
字符串
怎么做?像这样:
型
正如你所看到的,只有一个替换变量的提示。如果你重新执行相同的(最后一个)语句会怎么样?查询工作,但它使用以前输入的值:
型
如果你想使用一个新的值,undefine变量:
型