My query is:
SELECT vendor.id, insurances.id AS ins_id, vendor_insurances.expiry_date
FROM vendor
INNER JOIN vendor_insurances
ON vendor.id=vendor_insurances.vendor_id
and the output:
id ins_id expiry_date
================================
28 1 2006-01-01
28 11 2008-01-01
I want to convert it to:
id 1 11
======================================
28 2006-01-01 2008-01-01
Thanks,
You will need to use PIVOT and do something similar to this:
Static Pivot - for just a few number of columns that you will pivot
See SQL Fiddle for Working Demo
Or you can use a Dynamic Pivot if you have a lot of items to PIVOT:
Both will give you the same results.