Einzelnen Beitrag anzeigen

Benutzerbild von RWarnecke
RWarnecke

Registriert seit: 31. Dez 2004
Ort: Stuttgart
4.408 Beiträge
 
Delphi XE8 Enterprise
 
#8

AW: Einen gecasteten String mit Zeichen auffüllen in einer SQL Anweisung

  Alt 10. Mär 2013, 12:09
Hallo zusammen,

danke erstmal für die vielen Antworten. Ich habe jetzt eine für mich akzeptable Lösung gefunden. Vielleicht ein bisschen umständlich, aber sie funktioniert.
Code:
select facility.*,
       province.AaLong as AaProvinceLong,
       province.AaShort as AaProvinceShort,
       province.AaCenter as AaProvinceCenter,
       district.AaName as AaDistrictName,
       country.AaLong as AaCountryLong,
       country.AaShort as AaCountryShort,
       facility_type.AaShort as AaFacilityTypeShort,
       facility_type.AaLong as AaFacilityTypeLong,
       (AaProvinceShort + AaFacilityTypeShort + substring("000" + cast(facility.AiCode as string), Length("000" + cast(facility.AiCode as string)) - 3, Length("000" + cast(facility.AiCode as string)))) as AaCode  
   from (facility                                                                                                                                                                              
         LEFT JOIN province
         ON facility.AiProvince = province.SiProvince
         LEFT JOIN district
         ON facility.AiDistrict = district.SiDistrict
         LEFT JOIN country
         ON facility.AiCountry = country.SiCountry
         LEFT JOIN facility_type
         ON facility.AiFacilitytype = facility_type.SiFacilitytype
         )                        
   order by AaCode ASC;
Ich bin aber für weitere Vorschläge offen, wie man es komplett über SQL lösen kann.
Rolf Warnecke
App4Mission
  Mit Zitat antworten Zitat