Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Checking for existence [newbie]
mar wrote:
> I have to find out the existence of tasks
> for an employee, and for a time period.
>
> Now I do
>
> SELECT COUNT(*)
> FROM TASKS
> WHERE EMPNO = 239 AND
> TASK_DATE >= SYSDATE-4 AND
> TASK_DATE <= SYSDATE-1;
>
> If COUNT(*) gives value greater than 0,
> then I know that that employee had some tasks
> in the given time period. However is there
> a better trick? Function COUNT(*) is too
> slow and I have to find just ONE row.
SELECT 1
FROM TASKS
WHERE EMPNO = 239
AND TASK_DATE >= SYSDATE-4
AND TASK_DATE <= SYSDATE-1
AND ROWNUM = 1;
-- Daniel Morgan http://www.outreach.washington.edu/extinfo/certprog/oad/oad_crs.asp damorgan_at_x.washington.edu (replace 'x' with a 'u' to reply)Received on Thu May 15 2003 - 19:13:04 CDT