Solved

Interactive 'WITH' Statement

Posted on 2009-05-14
2
183 Views
Last Modified: 2012-05-07
Sample code not working and I don't see why.  Any suggestions?
Token ( was not valid. Valid tokens: FOR WITH FETCH ORDER UNION EXCE 
 WITH MYTABLE AS (SELECT DDCREW, DDDRV#,                              
   DATE(DDYEAR || DDMOTH || DDDAY) As strdate, ddmd from cdsddm)      
 select * from MYTABLE                                                
   where dddrv#=2523                                                  
    and strdate = 20090316

Open in new window

0
Comment
Question by:lynn_harris
2 Comments
 
LVL 18

Accepted Solution

by:
daveslash earned 50 total points
ID: 24390015

Since my date-format is *ISO, the following works for me:

WITH MYTABLE AS (
  SELECT 2523 as DDDRV#,
         DATE('2009' || '-' || '03' || '-' || '16') As strdate
  from   sysibm/sysdummy1)
select *
from   MYTABLE
where  dddrv#=2523
  and  strdate = '2009-03-16'
 
HTH,
DaveSlash

Open in new window

0
 

Author Closing Comment

by:lynn_harris
ID: 31581707
Thank You.  I will toy with my some more.  
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question