×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Perhaps you should move the case into a CTE, so that the column references can work....
with CT (ForMonthYear, Amt) as
(
SELECT case substr(digits(DATEFIELD), 5, 2) ||
substr(digits(DATEFIELD), 1,2)
when '7901' then '01/07 - Jan 07'
when '7902' then '02/07 - Feb 07'
when '7903' then '03/07 - Mar 07'
when '7904' then '04/07 - Apr 07'
when '7905' then '05/07 - May 07'
when '7906' then '06/07 - Jun 07'
else 'BYPASS' end,
AMT1
FROM FILE1
WHERE AMT1 > 49.99
)
SELECT ForMontYear, count(*), sum(Amt)
FROM CT
GROUP BY ForMonthYear
Eric
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx]On Behalf Of Alan Shore
Sent: Tuesday, December 18, 2007 9:34 AM
To: Midrange Systems Technical Discussion
Subject: SQL Case question
Hi everyone
I have an SQL question
I have a file with a date held in a 6 digit/numeric field (NOT my design)
in the format MMDDYY
here is my SQL statement
SELECT case substr(digits(DATEFIELD), 5, 2) || substr(digits(DATEFIELD), 1,
2)
when '7901' then '01/07 - Jan 07'
when '7902' then '02/07 - Feb 07'
when '7903' then '03/07 - Mar 07'
when '7904' then '04/07 - Apr 07'
when '7905' then '05/07 - May 07'
when '7906' then '06/07 - Jun 07' else 'BYPASS' end as ForMonthYear,
count(*), sum(AMT1) FROM FILE1 WHERE
AMT1 > 49.99 and
and 1 <> 'BYPASS' GROUP BY 1
when I run this I get the error
Column DATEFIELD or expression in SELECT list not valid.
DATEFIELD definitely is in FILE1
Is the problem with my CASE select?
If anyone can point me in the right direction, it would be MUCH appreciated
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.