| Author |
Topic |
|
abcd
Yak Posting Veteran
92 Posts |
Posted - 2009-03-30 : 07:48:45
|
| I have three tables Profile_UserDetails, Profile_SpouseDetails, Profile_ChildDetailsDetails of the table are as followsProfile_UserDetails with columns[Sno]—(pk) ,[EmpCode] ,[EmpInitial] ,[EmpFirstName] ,[EmpMiddleName] ,[EmpLastName] ,[DOB] ,[DOJ] ,[MobileNo] ,[LandlineNo] ,[PresentAddress] ,[ParmenantAddress] ,[MartialStatus] ,[Locality] ,[BloodGroup] ,[EmergencyContactNo] ,[EmergencyName] ,[CreatedBy](FK) ,[CreatedOn] ,[UserId]—(FK) Profile_SpouseDetails with columns [SpouseNo]—(PK) ,[UserId]—(FK) ,[SpouseName] ,[DOB] ,[BloodGroup] ,[AnniversaryDt]Profile_ChildDetails With columns[ChildId]—(PK) ,[UserId]—(FK) ,[ChildName] ,[ChildDOB] ,[ChildBloodGroup]UserId field is contained in other table as User_Login and is the primary key of that table…My Query is to find1.Display all the employees having DOb in some specific month2.If the employee is married then display the spouse details,AnniversaryDate etc..3.If the employee has children then then display the dob of the childreni.e whenever one selects a month the records we achieve display the full information about the employee ,spouse ,children if they have any occasion in the given month…Hope I am able to describe my problem fully,,, |
|
|
abcd
Yak Posting Veteran
92 Posts |
Posted - 2009-03-31 : 00:45:28
|
| Please do help....I have tried this much..but i am really confused how to carry on further...SELECTEname=Case When PSD.SpouseName is not null --and PCD.ChildName is null Then PUD.EmpFirstName+' '+isnull(PUD.EmpMiddleName,'')+ ' '+PUD.EmpLastName+'/'+PSD.SpouseName When PCD.ChildName is not null Then PUD.EmpFirstName+' '+isnull(PUD.EmpMiddleName,'')+ ' '+PUD.EmpLastName+'/'+PCD.ChildName Else PUD.EmpFirstName+' '+isnull(PUD.EmpMiddleName,'')+ ' '+PUD.EmpLastName END,PUD.MobileNo,PUD.DOB,PSD.AnniversaryDt,PSD.DOB as SpouseDOB,PCD.ChildDOBFROMProfile_UserDetails as PUDLeft join Profile_SpouseDetails as PSD on PUD.UserId=PSD.UserIdLeft Join Profile_ChildDetails as PCD on PUD.UserId=PCD.UserId |
 |
|
|
|
|
|