473,473 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Syntax Help!

Hi guys..

When I try and run the following code it says that there is a missing
operator..
SELECT
curr.portfolio_code,
curr.date,
(curr.gross_index-mo1.gross_index)/mo1.gross_index AS 1MONTH_RETURN,
(curr.gross_index-mo1.gross_index)/mo1.gross_index AS 3MONTH_RETURN
FROM portfolio_performance AS curr
LEFT OUTER JOIN portfolio_performance AS mo1
ON curr.date =
dateserial(year(dateadd('d',-1,dateserial(Year([mo1].date),
MONTH([mo1].date)+2, 1))),
month(dateadd('d',-1,dateserial(Year([mo1].date), MONTH([mo1].date)+2,
1))),day(dateadd('d',-1,dateserial(Year([mo1].date),MONTH([mo1].date)+2,

1))))
LEFT OUTER JOIN portfolio_performance AS mo3
ON curr.date =
dateserial(year(dateadd('d',-1,dateserial(Year([mo3].date),
MONTH([mo3].date)+4, 1))),
month(dateadd('d',-1,dateserial(Year([mo3].date), MONTH([mo3].date)+4,
1))),day(dateadd('d',-1,dateserial(Year([mo3].date),MONTH([mo3].date)+4,

1))))
;
However, when I run the same code, minus the second left outer join it
works perfectly..
SELECT
curr.portfolio_code,
curr.date,
(curr.gross_index-mo1.gross_index)/mo1.gross_index AS 1MONTH_RETURN
FROM portfolio_performance AS curr
LEFT OUTER JOIN portfolio_performance AS mo1
ON curr.date =
dateserial(year(dateadd('d',-1,dateserial(Year([mo1].date),
MONTH([mo1].date)+2, 1))),
month(dateadd('d',-1,dateserial(Year([mo1].date), MONTH([mo1].date)+2,
1))),day(dateadd('d',-1,dateserial(Year([mo1].date),MONTH([mo1].date)+2,

1))));
Any help would be appreciated.. im sure its only something minor!

May 2 '06 #1
3 1961
What flavour of SQL are you using ? This is a Microsoft SQL Server
group, but your code looks like a Microsoft Access query.

Razvan

May 2 '06 #2
Razvan,

Well its written as you would ANSI SQL but the dateadd function is
access... noone in the access newsgroup will help at all so i just
asked here to see if anyone here coul d help.

May 2 '06 #3
ja********@gmail.com (ja********@gmail.com) writes:
Well its written as you would ANSI SQL but the dateadd function is
access... noone in the access newsgroup will help at all so i just
asked here to see if anyone here coul d help.


Just because it's ANSI SQL does not mean that it will compile in any
DB engine. If the Access people does not know their syntax, how could
we know it.

First, try the query only with the FROM clause and the second LEFT JOIN,
to see if that works. If it does, you can rule out that you have an
error with the many parentheses.

Next try this syntax:

SELECT
FROM
LEFT OUTER JOIN
LEFT OUTER JOIN
ON
ON

I have an impression that Access prefers this order, unreadable as it may
be.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
May 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
22
by: Tuang | last post by:
I'm checking out Python as a candidate for replacing Perl as my "Swiss Army knife" tool. The longer I can remember the syntax for performing a task, the more likely I am to use it on the spot if...
4
by: Toonman | last post by:
I'm trying to use a couple of variables in a stored procedure. Things work fine when I hard code the data into the variables and also work fine when I use the variable in the WHERE clause and hard...
3
by: KevLow | last post by:
Hi, Hope some kind soul can help me out here.. I'm trying to programmatically modify the column headings of a crosstab query such that it can be dynamic based on user specified period (Month...
4
by: Bob hotmail.com> | last post by:
Everyone I have been spending weeks looking on the web for a good tutorial on how to use regular expressions and other methods to satisfy my craving for learning how to do FAST c-style syntax...
6
by: Scott Nixon | last post by:
New to Postgres 7.3 from 7.0. Am having some trouble with a query that worked in 7.0 but not in 7.3.....can't seem to figure out the syntax or find info about how to do this anywhere. ...
5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
13
by: usenet | last post by:
How and where can one find out about the basics of VB/Access2003 syntax? I am a died in the wool C/C++/Java Linux/Unix programmer and I am finding it difficult to understand the program format...
3
by: bearophileHUGS | last post by:
Probably you have already discussed this topic, but maybe you can stand touching it again briefly. Maybe properties aren't used so often to deserve a specific syntax, but I don't like their syntax...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.