miércoles, 26 de abril de 2023

SQL amb IIf imbricats Mid i InStr

 SELECT Mid(Sheet1.Field1,InStr(Sheet1.Field1,"; Di")+2,InStr(Sheet1.Field1,"h.;")-InStr(Sheet1.Field1,"; Di")) AS DiaHora, Mid(Sheet1.Field1,InStr(Sheet1.Field1,"; del "),InStr(Sheet1.Field1,"; Di")-InStr(Sheet1.Field1,"; del ")) AS DataData, Mid(Sheet1.Field1,InStr(Sheet1.Field1,"_M"),5) AS MP_UF_, 

IIf(InStr([Sheet1].[Field1], "IEA") > 0, 
IIf(  Mid([Sheet1].[Field1],InStr([Sheet1].[Field1],"IEA"),3)="IEA","IEA"), 

    IIf(InStr([Sheet1].[Field1], "GAD") > 0, 
IIf(  Mid([Sheet1].[Field1],InStr([Sheet1].[Field1],"GAD"),3)="GAD","GAD"),
 
    IIf(InStr([Sheet1].[Field1], "TAPSD") > 0, 
IIf(  Mid([Sheet1].[Field1],InStr([Sheet1].[Field1],"TAPSD"),3)="TAPSD","TAPSD"), 

    IIf(InStr([Sheet1].[Field1], "AFI") > 0, 
IIf(  Mid([Sheet1].[Field1],InStr([Sheet1].[Field1],"AFI"),3)="AFI","AFI"),

    IIf(InStr([Sheet1].[Field1], "EDI") > 0, 
IIf(  Mid([Sheet1].[Field1],InStr([Sheet1].[Field1],"EDI"),3)="EDI","EDI"),"")))))

AS Cicle1
FROM Sheet1;


No hay comentarios:

Publicar un comentario