473,396 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Syntax error in FROM Clause

Can someone please help me with this script?

PARAMETERS [Enter start date] DateTime, [Enter end date] DateTime;
SELECT "Jxx" AS [Batch ID], Q.POST_DT AS [Date], "Jxx" AS [Source Document], Trim(Left([Q].[DES],40)) AS Reference, Q.Account, CCur(IIf([Q].[Amt]>=0,Round([Q].[Amt],2),0)) AS [Debit Amount], CCur(IIf([Q].[Amt]<0,Round(abs([Q].[Amt]),2),0)) AS [Credit Amount], Q.REF AS [Distribution Reference], Q.CO_CD, CCur(Round([Q].[Amt],2)) AS AMT, IIf([q].[CO_CD]="AZ","MFAL","RTL") AS GP_Co, Trim(Q.CO_UNIT) AS CO_UNIT, Trim(Left(Q.CMNT,70)) AS CMNT
FROM SELECT
A.Co_Cd as CO_CD
, ( '257460' & A.Mkt_cd & A.Store_Cd ) AS [Account]
, 'TWF' AS EMP_CD_OP
, [Enter end date] AS POST_DT
, ( 'Mkt ' & A.Mkt_Cd & ' non-rtn ICA-' & trim( A.ITT_Sub_Cd ) & ' rcls ' & Format( [Enter end date],'yyyy-mm-dd') ) AS DES
, 'Non-rtn rcls' AS REF
, sum( -A.Cost_extended ) AS AMT
, trim(A.Store_cd) AS CO_UNIT
, ( A.Mkt_Store_Cd & ' non-rtn ICA-' & trim( A.ITT_Sub_Cd ) & ' reclass ' & Format( [Enter end date],'yyyy-mm-dd') ) AS CMNT
FROM [qITT_ICA_Not_from_Returns] AS A
where
A.ITT_Sub_Cd in ( [Enter Sub Cd] )
group by
A.Co_Cd
, A.Mkt_Store_Cd
, A.Mkt_Cd
, A.Store_cd
, A.ITT_Sub_Cd

UNION SELECT
A.Co_Cd as CO_CD
, ( switch( A.ITT_Sub_cd = 'CMF' , '2577', A.ITT_Sub_cd='WAR', '2570', TRUE, A.ITT_Sub_Cd & '!' ) & '60' & A.Mkt_cd & A.Store_Cd ) AS [Account]
, 'TWF' AS EMP_CD_OP
, [Enter end date] AS POST_DT
, ( 'Mkt ' & A.Mkt_Cd & ' non-rtn ICA-' & trim( A.ITT_Sub_Cd ) & ' rcls ' & Format( [Enter end date],'yyyy-mm-dd') ) AS DES
, 'Non-rtn rcls' AS REF
, sum( A.Cost_extended ) AS AMT
, trim(A.Store_cd) AS CO_UNIT
, ( A.Mkt_Store_Cd & ' non-rtn ICA-' & trim( A.ITT_Sub_Cd ) & ' reclass ' & Format( [Enter end date],'yyyy-mm-dd') ) AS CMNT
FROM [qITT_ICA_Not_from_Returns] AS A
where
A.ITT_Sub_Cd in ( [Enter Sub Cd] )
group by
A.Co_Cd
, A.Mkt_Store_Cd
, A.Mkt_Cd
, A.Store_cd
, A.ITT_Sub_Cd

AS Q
WHERE ((([Q].[AMT])<>0));
Oct 12 '07 #1
3 2201
iburyak
1,017 Expert 512MB
Half of statements here are not SQL rather VB statements like :

1.
Expand|Select|Wrap|Line Numbers
  1. IIf([q].[CO_CD]="AZ","MFAL","RTL") AS GP_Co, Trim(Q.CO_UNIT) AS CO_UNIT, Trim(Left(Q.CMNT,70)) AS CMNT
2.
Expand|Select|Wrap|Line Numbers
  1. Format( [Enter end date],'yyyy-mm-dd')
3. You have Select right after From what is it?
If you want to use internal table - put it in parenthesis and give it an alias like:

Expand|Select|Wrap|Line Numbers
  1. Select .....
  2. FROM ( Select ...... From ... Where ...) tmp

Are you sure you are in a right forum?
Is this Access?
Oct 12 '07 #2
Half of statements here are not SQL rather VB statements like :

1.
Expand|Select|Wrap|Line Numbers
  1. IIf([q].[CO_CD]="AZ","MFAL","RTL") AS GP_Co, Trim(Q.CO_UNIT) AS CO_UNIT, Trim(Left(Q.CMNT,70)) AS CMNT
2.
Expand|Select|Wrap|Line Numbers
  1. Format( [Enter end date],'yyyy-mm-dd')
3. You have Select right after From what is it?
If you want to use internal table - put it in parenthesis and give it an alias like:

Expand|Select|Wrap|Line Numbers
  1. Select .....
  2. FROM ( Select ...... From ... Where ...) tmp

Are you sure you are in a right forum?
Is this Access?
This is Access? I am in the wrong Forum. Apologies
Oct 12 '07 #3
iburyak
1,017 Expert 512MB
Anyway in Access you should create a separate query for internal result set and then use this query in from instead of Select statement.


You have

From Select ......

it should be
From Query_name
Oct 12 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
2
by: Martin | last post by:
I am now working on SQL Server 2000 having had previous experience on a different database. Both of the OUTER JOIN syntaxes is different from what I am used to and I am finding it slightly...
8
by: Jan van Veldhuizen | last post by:
The UPDATE table FROM syntax is not supported by Oracle. I am looking for a syntax that is understood by both Oracle and SqlServer. Example: Table1: id name city ...
2
by: sunny076 | last post by:
Hi, I am confused with the syntax for NOT in MYSQL where clause and wonder if an expert in MYSQL can enlighten me. There are possibly two places NOT can go in: select * from employee_data...
8
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. ...
4
by: James | last post by:
Please help me with this sql: SELECT z005aNORTHEAST_3days_Formula.Region, z005aNORTHEAST_3days_Formula.DiffofClaimsAssignment FROM (SELECT .Region, (.)-( .) AS DiffofClaimsAssignment FROM...
3
by: Jerry | last post by:
Well, here is some weirdness. First, I noticed that I have 2 Set keywords (silly me). so I removed the 2nd "Set" but still got a syntax error. Then I removed the Where clause, and now it works...
11
by: Frankie | last post by:
Hello: New user here...first post to group. I'm getting an SQL syntax error when I try to run the following query: $query = sprintf("SELECT itemNumber, entryDate, modifyDate, thumbnailURL,...
3
by: bilbo | last post by:
Can anybody help me understand why I get the error "Syntax error in CONSTRAINT clause"? I get it in Access 2003 and Access 2007. Both are clean installs with no add-ins Running this code in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.