Hello. My first post here and hope to get some help. It'll be obvious that I'm a newbie.I apologize for the length of this post but I want to provide as much information as possible. I hope it's understandable. Also hope that I'm posting correctly and to correct forum.I need some help with joins, and will appreciate any help. To make it as simple as possible, let's say I have five tables: WorkForce (large), Sales (large), ZipTable (small), Products (small), and Skills (small).WorkForce has fields empID and zip.Sales has fields empID, empNAME, payID, prodID, salesTot.ZipTable has fields zip.Products has fields prodID, prodType.PayTypes has fields payID, payTypeI need a report that shows the following:[u]Column[/u] - [u]Source or Table[/u]empID - WorkForce. Match 'zipCode' in 'WorkForce' table to 'zipCode' in the 'ZipTable' table to get 'empID' for all reportable employees (RE).empName - WorkForcezipCode - WorkForcepayType - Match 'payID' in Sales table to 'payID' in 'PayTypes' table to get payTypeprodType - Match 'prodID' in 'Sales' table to 'prodID' in the 'Products' table to get 'prodType'salesTot Total - Match 'empID' in 'Sales' to 'empID' in (RE) to get total 'salesTot' by 'payType' for all 'prodID' in 'Sales' table that match 'prodID' in 'Products' table for each reportable employee. I just can't get around syntax errors or get correct joins and need some help. Thanks for your time and help. Here's my latest attempt which gives syntax errors on 'FROM':[quote]SELECT WorkForce.empID, WorkForce.empName, WorkForce.zip, Sales.prodID, PayTypes.payType, Products.prodType, Sum(convert(int,Sales.salesTot) AS [SumOfsalesTot]FROM WorkForce INNER JOIN ZipTable ON WorkForce.zip = ZipTable.zip INNER JOIN Sales INNER JOIN Products ON Sales.prodID = Products.prodID ON WorkForce.empID = Sales.empID) INNER JOIN PayTypes ON Sales.payID = PayTypes.payIDGROUP BY WorkForce.empID, WorkForce.empName, WorkForce.zip, Sales.prodID, PayTypes.payType, Products.prodTypeORDER BY Sum(convert(int,Sales.salesTot) DESC;[/quote]
↧