Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple SQL syntax error

Status
Not open for further replies.

TheInsider

Programmer
Jul 17, 2000
796
0
0
CA
Hi,<br>&nbsp;Thanks to MalcolmW I have the idea of how to solve my last problem. I am fairly new to SQL and when I implemented a test case I got a syntax error in the FROM clause and the second SELECT keyword was highlighted. Below is the SQL statement:<br><br>PARAMETERS PID Text;<br>SELECT Clients.FirstName, Clients.MiddleInitial, Clients.LastName, qryQuantities.SumOfQuantity<br>FROM Clients RIGHT JOIN (<font color=blue><b>SELECT</b></font> Orders.SocialInsuranceNumber, Sum(Orders.Quantity) AS SumOfQuantity<br>FROM Orders WHERE (((Orders.ProductID)=[PID])) GROUP BY Orders.SocialInsuranceNumber) AS qryQuantities ON Clients.SocialInsuranceNumber = qryQuantities.SocialInsuranceNumber;<br><br>I think I'm missing a '(' or have one in the wrong place? I'm not proud to be asking for help on something this minor!<br><br>
 
Here is quickie example I made up using pubs:<br>SELECT au_lname<br> , au_fname<br> , SumPrice<br>FROM authors<br> INNER JOIN <br> (SELECT au_id, SumPrice = SUM(titles.price)<br> FROM (titleauthor AS Derived<br> INNER JOIN titles ON Derived.title_id = titles.title_id)<br> GROUP BY Derived.au_id) AS Derived <br>&nbsp; ON authors.au_id = Derived.au_id<br>Of course, you wouldn't have to use derived tables to get this result, but it does demonstrate how to use them to get this result. <p>Malcolm Wynden<br><a href=mailto:wynden@island.dot.net>wynden@island.dot.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top