May 1, 2008 at 8:18 am
WHY DOESNT THIS WORK:
SELECT C.CUS_PARENT,C.MACNUM,0 AS COUNT
FROM CUST_FILE C
WHERE C.CUS_DEACT_DATE = '2008-02-02';
0 AS COUNT IS A LITERAL STRING I HAVE IN THE SELECT BUT THE QUERY FAILS TO EXECUTE GIVING ME A LITERAL STRING ERROR. I TRIED PUTING SINGLE QUOTES AROUND IT AND EVEN DOUBLE QUOTES BUT IT STILL DOES NOT WORK.
DOES ANYONE HAVE A SUGGESTION?
THANKS
May 1, 2008 at 8:27 am
are you sure the zero is causing the problem, it's alias? try SELECT 0 as CNT instead of the reserved word COUNT
also, careful with the datefield...
it's good practice to use the oracle TO_DATE function:
.datefield=TO_DATE('04/14/2008',MM/DD/YYYY')
Lowell
May 1, 2008 at 8:30 am
What is the exact error message you are getting?
Is this query being run on SQL Server or ORACLE?
I ran a similar query in the AdventureWorks database on my machine and it did not return an error. If on SQL Server I would recommend against using COUNT as a column name since it is an aggregate function.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
May 1, 2008 at 8:33 am
THE ERROR I'M GETTING IS 'LITERAL DOES NOT MATCH FORMAT STRING' I AM RUNNING THIS ON ORACLE AND I CHANGED THE WORD COUNT TO CNT AND IT STILL DOES NOT WORK.
May 1, 2008 at 8:40 am
First, you might want to try asking your Oracle question on an Oracle forum... you'll usually get more correct answers that way... just a thought. 😉
Second, Oracle requires you to convert your literal date string to a date using TO_DATE like Lowell suggested.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 1, 2008 at 8:47 am
THAT WORKED THANKS
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply