troubleshooting Question

SQL Get a distinct list of items from a column in a query

Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland asked on
Visual Basic.NET
15 Comments1 Solution107 ViewsLast Modified:
Hi
I am trying to get a distinct list of items in one of the columns of a query using the following SQL but get the error
"Incorrect syntax near ')'"

	Select Distinct [Performance].[Hole Number] From (SELECT [Performance].Description, [Performance].[Shaft], [Performance].[Hole Number],  [Performance].[SAP Number], [vSAP_Shafts].[Rate] As Rate, Min([Performance].[Drilled From]) AS [From], Max([Performance].[Drilled To]) AS [To], Sum([Performance].[Drilled Total]) AS Advance, Sum([Performance].[Concrete Redrill]) AS ReDrill, Sum([Performance].Setup) AS Setups, Sum([Performance].[DWR Hours]) AS DWR, Sum([Performance].[Standing Time]) AS [Standing Time], Sum([Performance].[Grout Hours]) AS [Grout Hours], Sum([Performance].[Transport Hours]) as [Transport Hours], Sum([Performance].[Photographic Survey]) as [Photographic Survey], Sum([Performance].[Day Rate]) as [Day Rate], Sum([Performance].[Blank Cap]) as [Blank Cap], Sum([Performance].[Mobilise]) as [Mobilise] FROM [Performance] Left Join [vSAP_Shafts]  On ([Performance].Shaft = [vSAP_Shafts].Shaft And [Performance].[Description] = [vSAP_Shafts].[Description]) Where Date >= '16 Aug 2015' And Date <= '16 Aug 2015'  GROUP BY [Performance].[Hole Number], [Performance].Description, [Performance].[SAP Number], [vSAP_Shafts].[Rate], [Performance].Shaft  HAVING  [Performance].[Shaft] IN ('kopanang air')) 
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros