Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CONCAT DayofWeek Fields if Field Value =Y 3

Status
Not open for further replies.

kernal

Technical User
Feb 27, 2001
415
US
Dayofweek Values in the fields
MON Y
TUE Y
WED N
THU Y
FRI N

IF MON='Y' THEN 'M'
IF TUE='Y' THEN 'T'
IF WED='Y' THEN 'W'
IF THU='Y THEN 'H'
IF FRI='Y' THEN 'F'

Results needed
MTH since MON,TUE and THU has 'Y'

Thank you for your help!

 
SELECT
CASE
IF MON='Y'
THEN YOUR_STRING='M'
ELSE YOUR_STRING=''
IF TUE='Y'
THEN YOUR_STRING=YOUR_STRING || 'T'
IF WED='Y'
THEN YOUR_STRING=YOUR_STRING || 'W'
etc.

==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


 
Code:
SELECT DECODE(mon,'N',NULL,'M')||
       DECODE(tue,'N',NULL,'T')||
       DECODE(wed,'N',NULL,'W')||
       DECODE(thu,'N',NULL,'H')||
       DECODE(fri,'N',NULL,'F') AS schedule
  FROM Dayofweek;
 
much nicer and more concise solution, carp - have a star!

==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top