Hi,
I have gotten some help here before which has allowed me to convert a bunch of T-SQL statements to MySQL. But I am stumped on this one (this is just the IIF part):
This looks like the CASE statements are nested in other CASE statements. This is what I came up with (the whole query):
I don't thing I have converted the IIf to CASE statements correctly. I don't get any results and I should.
Hopefully @cheekybuddha can help here too.
Thanks for any help you all can provide.
I have gotten some help here before which has allowed me to convert a bunch of T-SQL statements to MySQL. But I am stumped on this one (this is just the IIF part):
Code:
IIf([tlkpSUHorz]![SUHorz]='Segment',[tlkpSUHorz]![SUHorz] & ' ' & [tblPD]![SUHorzID],
(IIf([tlkpSUHorz]![SUHorz]='Half' Or [tlkpSUHorz]![SUHorz]='Quadrant' Or ([tlkpSUHorz]![SUHorz]='Wall' And [tblPD].[SUHorzID] Is Not Null),[tlkpCardinalDirection]![Dir] & ' ' & [tlkpSUHorz]![SUHorz],[tlkpSUHorz]![SUHorz]))) AS [SU Horizontal],
IIf([tlkpSUVert].[SUVertESR2] Is Null,IIf([tblPD].[SUVertNum] Is Null,[tlkpSUvert].[SUVertESR1],[tlkpSUvert].[SUVertESR1] & ' ' & [tblPD].[SUVertNum]),IIf([tblPD].[SUVertNum] Is Null,[tlkpSUvert].[SUVertESR1],[tlkpSUvert].[SUVertESR1] & ' ' & [tblPD].[SUVertNum]) & ' ' & IIf([tblPD].[SUVertSubNum] Is Null,[tlkpSUvert].[SUVertESR2],[tlkpSUvert].[SUVertESR2] & ' ' & [tblPD].[SUVertSubNum])) AS [SU Vertical], [tlkpFAP].[FAPGen] & ': ' & [tlkpFAP].[FAPSpec] AS [Fill/Assemblage Position], [tlkpFAT].[FATGen] & ': ' & [tlkpFAT].[FATSpec] AS [Fill/Assemblage Type],
This looks like the CASE statements are nested in other CASE statements. This is what I came up with (the whole query):
Code:
SELECT tblPD.Site, tblPD.SUNum, tblPDSCP.SCPOrder, tblPD.PD,
CASE
WHEN tlkpSUHorz.SUHorz = 'Segment' THEN CONCAT(tlkpSUHorz.SUHorz, ' ', tblPD.SUHorzID)
ELSE
CASE
WHEN tlkpSUHorz.SUHorz = 'Half' OR tlkpSUHorz.SUHorz = 'Quadrant' OR tlkpSUHorz.SUHorz = 'Wall' AND tblPD.SUHorzID IS NOT NULL
THEN CONCAT(tlkpCardinalDirection.Dir, ' ', tlkpSUHorz.SUHorz)
ELSE tlkpSUHorz.SUHorz
END
END AS SUHorizontal,
CASE
WHEN tlkpSUVert.SUVertESR2 IS NULL
THEN
CASE
WHEN tblPD.SUVertNum IS NULL THEN tlkpSUvert.SUVertESR1
ELSE CONCAT(tlkpSUvert.SUVertESR1, ' ', tblPD.SUVertNum)
END
ELSE
CASE
WHEN tblPD.SUVertNum IS NULL THEN tlkpSUvert.SUVertESR1
ELSE CONCAT(tlkpSUvert.SUVertESR1, ' ', tblPD.SUVertNum, ' ',
CASE
WHEN tblPD.SUVertSubNum IS NULL THEN tlkpSUvert.SUVertESR2
ELSE CONCAT(tlkpSUvert.SUVertESR2,' ', tblPD.SUVertSubNum)
END )
END
END AS SUVertical,
CONCAT(tlkpFAP.FAPGen, ': ', tlkpFAP.FAPSpec) AS FillAssemblagePosition,
CONCAT(tlkpFAT.FATGen, ': ', tlkpFAT.FATSpec) AS FillAssemblageType,
tblPDSCP.SCPDesc
FROM tlkpFAT RIGHT JOIN (tlkpFAP RIGHT JOIN ((tlkpSUVert RIGHT JOIN (tlkpSUHorz RIGHT JOIN (tblPD LEFT JOIN tblPDSCP ON (tblPD.PD = tblPDSCP.PD) AND (tblPD.Site = tblPDSCP.Site)) ON tlkpSUHorz.SUHorzCode = tblPD.SUHorzCode) ON tlkpSUVert.SUVertCode = tblPD.SUVertCode) LEFT JOIN tlkpCardinalDirection ON tblPD.SUHorzID = tlkpCardinalDirection.DirCode) ON tlkpFAP.FAPCode = tblPD.FAPCode) ON tlkpFAT.FATCode = tblPD.FATCode
WHERE tblPD.Site = '5MT765' AND tblPD.SUNum = '1220' AND tblPD.FeNum IS NULL
ORDER BY tblPDSCP.SCPOrder, tblPD.PD
I don't thing I have converted the IIf to CASE statements correctly. I don't get any results and I should.
Hopefully @cheekybuddha can help here too.
Thanks for any help you all can provide.