select
    'ORGANISATION' as entity_type,
    cast(o.oid as varchar(128)) as source_entity_id,
    cast(o.GUID as varchar(64)) as source_external_key,
    coalesce(nullif(o.name, ''), nullif(o.kurzbez, ''), cast(o.oid as varchar(128))) as display_name,
    cast(case when o.gueltigbis is null or o.gueltigbis > getutcdate() then 1 else 0 end as bit) as active,
    o.VertragGiltAb as valid_from,
    o.gueltigbis as valid_to,
    cast(null as datetime) as source_updated_at,
    o.oid as organisation_id,
    cast(o.GUID as varchar(64)) as organisation_guid,
    o.kurzbez as organisation_code,
    o.name as organisation_name,
    cast(o.n_rekey01 as varchar(128)) as parent_organisation_id,
    o.Unternehmens_ID as company_id,
    o.kostenstelle as cost_center,
    o.Country as country,
    o.PostalCode as postal_code,
    o.City as city,
    o.strasse as street,
    o.Email as email
from dbo.I_90021 o
