Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sql query error

Posted on 2009-07-01
4
Medium Priority
?
311 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 93

Expert Comment

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

Accepted Solution

by:
Patrick Matthews earned 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
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…
Viewers will learn how the fundamental information of how to create a table.

636 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