0

I have to create a stored procedure by using 3 tables,1st is Registration table,job seeker table,employment detail table. In that I am having entries in 1st two tables.Till now I am not having any entry in employment detail table.

I am having following query:

select RD.FirstName,RD.LastName,
(select case when JR.profileHeadline=''
then 'No Resume Headline mentioned' 
else JR.profileHeadline end
from jobseekerReg JR)as profileHeadline ,
(select case when ED.designation=''
then 'No designation mentioned'
else ED.designation end
from employmentDetail ED)as designation,
(select case when ED.companyName=''
then 'No company name mentioned'
else ED.companyName end
from employmentDetail ED) as companyName,JR.location,
(select case when ED.funcArea=''
then 'No functional area mentioned'
else ED.funcArea end
from employmentDetail ED) as funcArea ,
(select case when ED.cmpIndustry=''
then 'No industry mentioned'
else ED.cmpIndustry end
from employmentDetail ED)as cmpIndustry,RD.BirthDay,
RD.Gender,JR.experience,
(select case when ED.salary=''
then 'No salary mentioned'
else ED.salary end
from employmentDetail ED)as salary ,JR.mobileNumber,JR.emailId,
JR.altEmailID,JR.jobSeekerAddrs,JR.maritalStatus,
(select case when JR.keySkills=''
then 'No keyskills mentioned'
else JR.keySkills end
from jobseekerReg JR)as keySkills
from RegistrationDetails RD join jobseekerReg JR on RD.Reg_Id=JR.regId
left outer join employmentDetail ED on ED.regId=JR.regId 
and ED.regId=2  where RD.Reg_Id=JR.regId and RD.Reg_Id=2 and JR.regId=2

The above query gives me correct output,but the problem is as I am not having any entry in employment table for regId=2, columns in this table gives output as null. how should I handle this problem? suggest me any solution Thanks in advance.

1
  • Use IsNull(fieldname, 'default value') to set default data to null fields if that is what you want. Else there could be problem with populating the field with values. Commented Oct 1, 2013 at 10:03

1 Answer 1

1
CASE WHEN ED.Salary IS NULL THEN 'No salary mentioned' ELSE ED.Salary END

But I think that in your case ISNULL() would be better:

select RD.FirstName,RD.LastName,
ISNULL(JR.profileHeadline, 'No Resume Headline mentioned') as profileHeadline ,
ISNULL(ED.designation, 'No designation mentioned') as designation,
ISNULL(ED.companyName, 'No company name mentioned')  as companyName, 
JR.location,
ISNULL(ED.funcArea, 'No functional area mentioned') as funcArea ,
ISNULL(ED.cmpIndustry, 'No industry mentioned') as cmpIndustry,
RD.BirthDay,
RD.Gender, JR.experience,
ISNULL(ED.salary, 'No salary mentioned' as salary ,
JR.mobileNumber,JR.emailId,
JR.altEmailID,JR.jobSeekerAddrs,JR.maritalStatus,
ISNULL(JR.keySkills, 'No keyskills mentioned') as keySkills
from RegistrationDetails RD join jobseekerReg JR on RD.Reg_Id=JR.regId
left outer join employmentDetail ED on ED.regId=JR.regId 
and ED.regId=2  where RD.Reg_Id=JR.regId and RD.Reg_Id=2 and JR.regId=2
Sign up to request clarification or add additional context in comments.

2 Comments

the above query works fine for fields from employment details.And it is not giving any value in fields from registration table and job seeker table
@AshwiniAgivalem, you should look for a problem in your data. Have I answered on your original question?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.