473,394 Members | 1,761 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,394 software developers and data experts.

How to fix syntax errors in this query?

Expand|Select|Wrap|Line Numbers
  1. SELECT     EmpID, amount, CASE isnull(StartDate, '') WHEN '' THEN CONVERT(varchar, cast('06/30/2010' AS datetime), 101) ELSE CONVERT(varchar, StartDate, 
  2.  
  3.                       101) END AS StartDate, percentage, PayrollCompany, [41] AS Period1, [42] AS Period2
  4.  
  5. FROM         (SELECT     t .EmpID, amount, StartDate, percentage, PayrollCompany
  6.  
  7.                        FROM          ESPPPeople e, PeriodInformation p, tmpEmpcontribution t
  8.  
  9.                        WHERE      t .EmpID = e.empID AND t .Period *= p.PeriodID) AS p PIVOT(MAX(EmpID) FOR Period IN ([41], [42])) AS pvt
  10.  
  11. ORDER BY pvt.EmpID, pvt.Period;
Feb 1 '11 #1
7 1872
gpl
152 100+
Is *= a part of the tsql language? If not, theres your problem, you need to add in some inner and left outer join statements
Feb 1 '11 #2
No even if i remove that condition I 'l get the same message....i get error as "incorrect syntax near PIVOT"
Feb 1 '11 #3
Rabbit
12,516 Expert Mod 8TB
So many errors...
  1. You have *= instead of just =
  2. You have a lot of spaces between the table qualifier and the field qualifier, i.e. t .fieldname instead of t.fieldname
  3. You don't return Period as a field in your subquery
  4. You seem to be trying to create the pivot fields in the select clause when you only have to do so in the pivot clause
Feb 1 '11 #4
the spaces it is taking automatically even if i remove.pivot clause syntax specifies after select clause pivoted fields have to be written ..now am getting confused
Feb 2 '11 #5
Rabbit
12,516 Expert Mod 8TB
In the SELECT clause, you specify the field to be pivoted, not the pivoted fields. You specify the pivoted fields in the PIVOT clause. But you don't even return the field you're trying to pivot so you're trying to pivot on a field that doesn't exist.
Feb 2 '11 #6
ck9663
2,878 Expert 2GB
Also, *= is the old way of doing a LEFT JOIN. If you remove the asterisk, it will become an INNER JOIN. Try to use the ANSI Standard of doing a join by specifying LEFT or INNER join, whichever case you need it to be.

Happy Coding!!!

~~ CK
Feb 2 '11 #7
hey guys thank u....i ve fixed it .....
Feb 3 '11 #8

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

Similar topics

1
by: Raphael Gluck | last post by:
Hi everyone I have a page on my site in which i wish to display links to brochures, and i have stored an index of these links in my database. however when i pass from the master page,...
8
by: Dalan | last post by:
Please help - just take a quick look at the function code below. It probably just needs some minor tweaking. The function module is based on an intermediate query to provide a group record...
1
by: maneeshkhare | last post by:
I am trying to update a field in Access db (.mdb) via a DataSet using the following code. I am continously getting this error: Has anybody seen this before? 1. If I try using the same code for...
1
by: amitbadgi | last post by:
I am geting the following error while conv an asp to asp.net Exception Details: System.Runtime.InteropServices.COMException: Syntax error in query expression 'id =System.__ComObject'. Source...
2
by: Roy Rodsson via .NET 247 | last post by:
Hi all! I am using a stored procedure in SQL2000 for retrieving fileinformations from a db. the table as an uniqueidentifier for the file information. The stored procedure has a variable...
2
by: Tom Baxter | last post by:
I have a numeric column in a query called Prov1.Volume. When I try taking the sum of that column (using SUM aggregate function in Design View) it gives a syntax error. It says that...
18
by: rahuls | last post by:
Hi everyone, I have a couple of questions? 1.this is part of my main function ////////////////////////////// int main() { FILE *f1; int i,j; j=100000000; int intData;
4
by: veer | last post by:
Hi i am running a date query squery = "Insert into " & txttablename & " IN '" & txtdatabase & " ' select * from " & sTableName & " IN '" & txtfolderpath & "\" & sArrFolder(icount) & "\" &...
5
by: OzNet | last post by:
Can someone tell me what I am doing wrong here please? I have a form with two unbound text boxes formatted to short date and an OK button. My button code is as follows: Private Sub...
7
by: Yesurbius | last post by:
I am receiving the following error when attempting to run my query. In my mind - this error should not be happening - its a straight-forward query with a subquery. I am using Access 2003 with all...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
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...

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.