Here is the MySQL query for my tables here:
SELECT vc.vehicle_class_name
, GROUP_CONCAT(CASE WHEN v.status = 2 THEN v.vehicle_id END) completed
, GROUP_CONCAT(CASE WHEN v.status <> 2 THEN v.vehicle_id END) incomplete
FROM vehicle_class vc
JOIN vehicle v
ON v.vehicle_class_id = vc.vehicle_class_id
GROUP
BY vc.vehicle_class_id;
I need help converting in Oracle9i, DB2 and SQL Server.
Please help.
Here is an Oracle9i solution.
The job is done with SYS_CONNECT_BY_PATH function which needs CONNECT BY clause in the query. In order to connect rows by something VEHICLE table is “prepared”… it is filled in with curr and prev row numbers.