-- Database schema
| cars : id [ INTEGER ] primary_key , train_id [ INTEGER ] cars.train_id = trains.id , position [ INTEGER ] , shape [ TEXT ] , len [ TEXT ] , sides [ TEXT ] , roof [ TEXT ] , wheels [ INTEGER ] , load_shape [ TEXT ] , load_num [ INTEGER ] | trains : id [ INTEGER ] primary_key , direction [ TEXT ] |
-- -- What is the percentage of all the trains with at least 4 cars? List the directions of the said trains.

SELECT CAST(COUNT(CASE WHEN T2.trailPosi >= 4 THEN T1.id ELSE NULL END) AS REAL) * 100 / COUNT(T1.id) FROM trains AS T1 INNER JOIN ( SELECT train_id, MAX(position) AS trailPosi FROM cars GROUP BY train_id ) AS T2 ON T1.id = T2.train_id UNION ALL SELECT T1.direction FROM trains AS T1 INNER JOIN ( SELECT train_id, MAX(position) AS trailPosi FROM cars t GROUP BY train_id ) AS T2 ON T1.id = T2.train_id AND T2.trailPosi >= 4;