Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Checking for existence [newbie]

Re: Checking for existence [newbie]

From: Daniel Morgan <damorgan_at_exxesolutions.com>
Date: Thu, 15 May 2003 17:13:04 -0700
Message-ID: <3EC42D10.C26592F5@exxesolutions.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US