Example

SELECT v.stock_number AS stock_number, DATE_FORMAT(v.ready_date, '%m/%d/%Y') AS ready_date, CASE WHEN vs.repair_id = 74 AND vs.status_id = 18 THEN 'X' ELSE '' END AS headliner, CASE WHEN v.check_in_validated_date IS NULL THEN '' ELSE 'X' END AS inspections, CASE WHEN vs.repair_id = 213 AND vs.status_id = 18 THEN 'X' ELSE '' END AS maaco, CASE WHEN v.detailed = 1 THEN 'X' ELSE '' END AS clean_up, TIMESTAMPDIFF(WEEK, v.ready_date, NOW()) AS week, CASE WHEN vs.status_id != 18 THEN '' ELSE 'X' END AS mechanical FROM vehicle v LEFT JOIN accessory_relation ar ON ar.vehicle_id = v.id LEFT JOIN vts_steps vs ON vs.vehicle_id = v.id WHERE v.id IN(SELECT v.id FROM vehicle v WHERE v.load_id='6' AND v.ready_date IS NOT NULL)
SQL Snippet

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.