Hello,
I have an SQL query that I'm using to ensure that names are populated as best as they can be where one or more of the fields are not poplated. ie, if there is no title, or no inititals, or no first name etc.
For reasons I can't go into, I cannot just create a view and use the view in the report linked to one of the existing report tables, so i need to recreate this case statement within a formula in crystal, but I'm stuck. Can someone help me out?
The SQL is as follows:
select iindividualid , "Name_Field" =
case
when isnull(vchsalutation, '') <> '' and isnull(vchinitials,'') <> '' and vchlastname <> '' then
vchsalutation + ' ' + vchinitials + ' ' + vchlastname
when isnull(vchsalutation, '') <> '' and isnull(vchinitials,'') = '' and vchfirstname = '' and vchlastname <> '' then
vchsalutation + ' ' + vchlastname
when isnull(vchsalutation, '') <> '' and isnull(vchinitials,'') = '' and vchlastname <> '' then
vchsalutation + ' ' + left(vchfirstname,1) + ' ' + vchlastname
when isnull(vchsalutation, '') = '' and vchfirstname <> '' and vchlastname <> '' then
vchfirstname + ' ' + vchlastname
when isnull(vchsalutation, '') = '' and vchfirstname = '' and vchlastname <> '' and isnull(vchinitials,'') <> '' then
vchinitials + ' ' + vchlastname
when isnull(vchsalutation, '') = '' and vchfirstname = '' and vchlastname = ' ' and isnull(vchinitials,'') = '' then
'No Name Details Found'
else 'Mr ' + vchlastname
end
Thanks,
Natasha
I have an SQL query that I'm using to ensure that names are populated as best as they can be where one or more of the fields are not poplated. ie, if there is no title, or no inititals, or no first name etc.
For reasons I can't go into, I cannot just create a view and use the view in the report linked to one of the existing report tables, so i need to recreate this case statement within a formula in crystal, but I'm stuck. Can someone help me out?
The SQL is as follows:
select iindividualid , "Name_Field" =
case
when isnull(vchsalutation, '') <> '' and isnull(vchinitials,'') <> '' and vchlastname <> '' then
vchsalutation + ' ' + vchinitials + ' ' + vchlastname
when isnull(vchsalutation, '') <> '' and isnull(vchinitials,'') = '' and vchfirstname = '' and vchlastname <> '' then
vchsalutation + ' ' + vchlastname
when isnull(vchsalutation, '') <> '' and isnull(vchinitials,'') = '' and vchlastname <> '' then
vchsalutation + ' ' + left(vchfirstname,1) + ' ' + vchlastname
when isnull(vchsalutation, '') = '' and vchfirstname <> '' and vchlastname <> '' then
vchfirstname + ' ' + vchlastname
when isnull(vchsalutation, '') = '' and vchfirstname = '' and vchlastname <> '' and isnull(vchinitials,'') <> '' then
vchinitials + ' ' + vchlastname
when isnull(vchsalutation, '') = '' and vchfirstname = '' and vchlastname = ' ' and isnull(vchinitials,'') = '' then
'No Name Details Found'
else 'Mr ' + vchlastname
end
Thanks,
Natasha