I am trying to write a query to display to a data control.
I’m having some issues trying to get the query I need.
I want the grid to to display:
product name dealer 1 dealer 2 dealer 3 dealer 4, etc <br/>
product a 10 12 18 N/A <br/>
product b 32 N/A 7 4 <br/>
product c 35 36 21 18 <br/>
Database Tables:
products
id, name
dealers
id, name
products_to_dealers_xref
product_id, dealer_id, qty
I can’t figure out how to get the query to layout like this.
I’m currently trying the UNION statement, but still can’t get it.
Any thoughts or ideas?
Thanks!
You need to pivot the results of the query using the PIVOT Operator
P. S.: not tested.