Complex SELECT statement; one-to-many all details in one row

Posted by RubyWedge on Stack Overflow See other posts from Stack Overflow or by RubyWedge
Published on 2010-02-21T07:01:22Z Indexed on 2010/04/29 14:27 UTC
Read the original article Hit count: 125

Filed under:
|
|
|

There are two tables:

Products
ID (Primary Key),
ProductName

PlannedByMonths
ProductID (Primary Key) (Link to the Products table many-to-one),
MonthNumber (Primary Key),
QtytoProduce,

How to write SELECT statement to retrieve results in the following format?

ProductName, QtytoProduceMonth1, QtytoProduceMonth2, QtytoProduceMonth3, QtytoProduceMonth4, QtytoProduceMonth5, QtytoProduceMonth6, QtytoProduceMonth7, QtytoProduceMonth8, QtytoProduceMonth9, QtytoProduceMonth10, QtytoProduceMonth11, QtytoProduceMonth12

Thank you.

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql