RE: SQl Query Help!!!!!

RE: SQl Query Help!!!!!

 

  


Abhishek,

The query below should serve your requirement:

select flag from test_sk where to_date('13-aug-2006','DD-mon-YYYY')
between start_date and nvl(end_date,sysdate)


Cheers,
Shanti

-----Original Message-----
From: abishek
[mailto:oracledba-ezmlmshield-x38555676.[Email address protected]
Sent: Monday, September 04, 2006 2:55 PM
To: LazyDBA Discussion
Subject: SQl Query Help!!!!!


I have the following table(table_name)

Plant Dc Flag Start_week End_week
---------------------------------------------------------------
6745 2834 X 6-AUG-06 10-SEP-06
6745 2834 M 11-SEp-06 NULL

There are many others records in this table..



I need to select the flag for the plant '6745' based on week falling
between the start_week column and end_week column.
For eg: 1) If the week is august 13 then 'X' flag should be selected
2) If the week is September 17 then 'M' flag should be
selected

I issued the following query..

SELECT t1.FLAG
FROM table_name t1,
(SELECT MIN(start_date) AS startdate
FROM table_name
WHERE TO_DATE('aug 13,06','mm/dd/yyyy') >= start_date
AND (TO_DATE('aug 13,06','mm/dd/yyyy') <= end_date OR end_date
IS NULL)) t2
WHERE t1.start_date = t2.startdate
AND t1.plant = '6745';


The above query using inline view is not working.It returns "no rows
selected". Please help me in correcting my query.



Thanks,
Abishek




The information contained in this electronic message and any attachments
to this message are intended for the exclusive use of the addressee(s)
and may contain proprietary, confidential or privileged information. If
you are not the intended recipient, you should not disseminate,
distribute or copy this e-mail. Please notify the sender immediately and
destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient
should check this email and any attachments for the presence of viruses.
The company accepts no liability for any damage caused by any virus
transmitted by this email.

www.wipro.com


---------------------------------------------------------------------
TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html



============================================================================================================================

Tech Mahindra, formerly Mahindra-British Telecom.

Disclaimer:

This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review at <a href="http://www.techmahindra.com/Disclaimer.html">http://www.techmahindra.com/Disclaimer.html</a> externally and <a href="http://tim.techmahindra.com/Disclaimer.html">http://tim.techmahindra.com/Disclaimer.html</a> internally within Tech Mahindra.

============================================================================================================================

Oracle LazyDBA home page