SELECT
	id,
	paying_id,
	paying_sub_code as seq_number,
	CASE credit_type_id WHEN 1 THEN 2 WHEN 2 THEN 1 ELSE credit_type_id END as credit_type_code,
	paying_amount as amount,
	bank_id,
	bill_date,
	bill_number,
	NULL as note,
	NOW() as created_at,
	NOW() as updated_at
FROM paying_details
INTO OUTFILE "/tmp/paying_details.csv" FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"';