SELECT  
num_noi AS 'CLAVE TRABAJADOR',
p_apellido AS 'A. PATERNO',
s_apellido AS 'A. MATERNO',
nombre AS 'NOMBRE(S)',
sd AS 'SALARIO DIARIO',
sexo AS 'SEXO',
Date_format(fecha_nac,'%d/%m/%Y') AS 'FECHA DE NACIMIENTO',
fecha_ing AS 'FECHA DE ALTA',
nss AS 'IMSS',
estado_noi AS 'LUGAR DE NACIMIENTO',
curp AS 'CURP',
rfc AS 'RFC',
calle AS 'CALLE',
colonia AS 'COLONIA',
municipio AS 'POBLACION',
cp AS 'CODIGO POSTAL',
cp AS 'CODIGO POSTAL FISCAL',
'21' AS 'ENTIDAD FEDERATIVA',
telefono AS 'TELEFONO 1',
telefono AS 'TELEFONO 2',
CASE
WHEN email IS NULL THEN 'correo@correo.com'
WHEN LENGTH(email) = 0 THEN 'correo@correo.com'
ELSE email
END AS 'CORREO ELECTRONICO',
CASE
WHEN email IS NULL THEN 'correo@correo.com'
WHEN LENGTH(email) = 0 THEN 'correo@correo.com'
ELSE email
END AS 'CORREO ELECTRONICO 2', 
'3' AS 'NIVEL DE ESTUDIOS',
' ' AS 'PROFESION', 
'0' AS 'ESTADO CIVIL',
'3' AS 'TIPO DE SANGRE',
beneficiario AS 'NOMBRE DE EMERGENCIA', 
telefono AS 'TELEFONO DE EMERGENCIA',
'T' AS 'FORMA DE PAGO', 
'012' AS 'BANCO OPERADOR', 
'0' AS 'LOCALIDAD/SUCURSAL',
tarjeta AS 'CONTROL DE BANCO',
cuenta AS 'CUENTA DEPOSITO',
CASE
WHEN n_sindicato='4' THEN 'C'
ELSE 'S'
END AS 'TIPO DE EMPLEADO', 
'1' AS 'TIPO DE JORNADA', 
turno_noi AS 'TURNO',
'0' AS 'UNIDAD MEDICA FAMILIAR', 
'0' AS 'DESCUENTO PENSION ALIMENTICIA', 
'Y4626877106' AS 'REGISTRO PATRONAL',
noi_sindicato AS 'CLASIFICACION', 
noi_departamento AS 'DEPARTAMENTO', 
noi_puesto AS 'PUESTO',
'P' AS 'TIPO DE CONTRATO', 
'1' AS 'TIPO DE INGRESOS', 
'Mexico' AS 'PAIS',
'02' AS 'CLAVE DE REGIMEN DE CONTRATACION',
' ' AS 'BASE DE COTIZACION',
'01' AS 'CLAVE DE TIPO DE CONTRATO V12',
'01' AS 'CLAVE DE TIPO DE JORNADA V12',
'PUE' AS 'CLAVE DE ENTIDAD FEDERATIVA V12',
' ' AS 'RUTA PLANTILLA',
'02' AS 'CLAVE REGIMEN DE CONTRATO V12',
'012' AS 'CLAVE DE BANCO OPERADOR V12',
'5' AS 'TABLA DE VACACIONES',
'4' AS 'TABLA DE SAL. DIARIO',
sdi AS 'SDI CAPTURADO',
'0' AS 'DIAS_CONTRATO'
FROM ftrabajador
WHERE noi_status='Nuevo'
AND num_noi between 20000 and 99999
ORDER BY num_noi ASC