Solved

sql query error

Posted on 2009-07-01
4
306 Views
Last Modified: 2012-05-07
I am getting error for the line where i am trying to convert date.

Msg 102, Level 15, State 1, Line 3
Incorrect syntax '('.  

Do i have my syntax wrong

(MAX(CONVERT(VARCHAR(10)(p21_sales_history_view.invoice_date),101) AS [Sales Date]
SELECT     p21_sales_history_view.salesrep_id, 
                      p21_sales_history_view.salesrep_first_name + ' ' + p21_sales_history_view.salesrep_last_name AS [Sales Rep], p21_item_view.upc_code, 
                      p21_sales_history_view.cogs_amount, MAX(CONVERT(VARCHAR(10)(p21_sales_history_view.invoice_date),101) AS [Sales Date]
FROM         p21_sales_history_view INNER JOIN
                      p21_item_view ON p21_sales_history_view.item_id = p21_item_view.item_id
WHERE     (p21_sales_history_view.supplier_id IN (101127, 105144, 101942, 101427, 101324, 101351, 101637, 101615, 101120, 101315))
GROUP BY p21_sales_history_view.salesrep_id, p21_item_view.upc_code, p21_sales_history_view.cogs_amount, p21_sales_history_view.supplier_id, 
                      p21_sales_history_view.salesrep_first_name + ' ' + p21_sales_history_view.salesrep_last_name

Open in new window

0
Comment
Question by:Jiggens
  • 2
  • 2
4 Comments
 
LVL 17

Expert Comment

by:pssandhu
ID: 24756817
Try this, you are missing a comma:
SELECT     p21_sales_history_view.salesrep_id, 
                      p21_sales_history_view.salesrep_first_name + ' ' + p21_sales_history_view.salesrep_last_name AS [Sales Rep], p21_item_view.upc_code, 
                      p21_sales_history_view.cogs_amount, MAX(CONVERT(VARCHAR(10),(p21_sales_history_view.invoice_date),101) AS [Sales Date]
FROM         p21_sales_history_view INNER JOIN
                      p21_item_view ON p21_sales_history_view.item_id = p21_item_view.item_id
WHERE     (p21_sales_history_view.supplier_id IN (101127, 105144, 101942, 101427, 101324, 101351, 101637, 101615, 101120, 101315))
GROUP BY p21_sales_history_view.salesrep_id, p21_item_view.upc_code, p21_sales_history_view.cogs_amount, p21_sales_history_view.supplier_id, 
                      p21_sales_history_view.salesrep_first_name + ' ' + p21_sales_history_view.salesrep_last_name

Open in new window

0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24756842
(MAX(CONVERT(VARCHAR(10), p21_sales_history_view.invoice_date, 101) AS [Sales Date]
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 24756848
Make that:

MAX(CONVERT(VARCHAR(10), p21_sales_history_view.invoice_date, 101)) AS [Sales Date]
0
 
LVL 17

Expert Comment

by:pssandhu
ID: 24756891
Opps.. that's right. You are missing a bracket too as mathew pointed out...
P.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question