Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Joining results of 2 Queries

Author  Topic 

charul
Starting Member

18 Posts

Posted - 2009-03-19 : 05:14:16
I have a query like this

Select Distinct A. ED_EMPCode [Code],
LTRIM(RTRIM(ISNULL(A.ED_Salutation,'')))+' '+LTRIM(RTRIM(ISNULL(A.ED_FirstName,'')))+' '+LTRIM(RTRIM(ISNULL(A.ED_MiddleName,'')))+' '+ LTRIM(RTRIM(ISNULL(A.ED_LastName,'')))
as [Employee Name],
B. ED_EMPCode [Respondent Code] ,
LTRIM(RTRIM(ISNULL(B.ED_Salutation,'')))+' '+LTRIM(RTRIM(ISNULL(B.ED_FirstName,'')))+' '+LTRIM(RTRIM(ISNULL(B.ED_MiddleName,'')))+' '+ LTRIM(RTRIM(ISNULL(B.ED_LastName,'')))
as [Respondent Name] ,RT_Desc as [RT_Type] ,
RT_ID
from ReqRec_EmployeeDetails A ,Setup_OrgEmployeeMaster,PMS_TempAppraiseeMap,PMS_RespondentEmpMap,ReqRec_EmployeeDetails B,
PMS_RespondentType
where A.ED_EmpCode=ORGEM_EmpCode and A.ED_EmpID=TEM_EMPID and A.ED_EmpID=REM_Appraisee_ID
and REM_Respondent_Id=B.ED_EmpID and RT_ID=REM_RT_ID and A.Ed_Status in (1,4) and
A.ED_EmpCode in ('00012','00034','00072')

This gives the following results:

00012 Raju Thakur 00012 Raju Thakur Self 1
00012 Raju Thakur 00063 Sarikonda Janardhan Appraiser 2
00012 Raju Thakur 00069 Rakesh Gopalkishan Biyani HR 4


Now i want to join the above query with another one


(Select 'KRA Score' as [Screen],EPWS_TotWeightageScore,EPWS_REM_Appraisee_ID,EPWS_RespondentType from PMS_EmpPMSWeightageScore
where EPWS_TM_ID in (Select TFBM_TempId from PMS_TemplateFeedBackMapping where TFBM_id in (1,5)))
UNION
(Select 'Competency Score' as [Screen],EPWS_TotWeightageScore,EPWS_REM_Appraisee_ID,EPWS_RespondentType from PMS_EmpPMSWeightageScore where
EPWS_TM_ID in (Select TFBM_TempId from PMS_TemplateFeedBackMapping
where TFBM_id in (1,5)))

How to do this?

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-19 : 06:54:32
You should format your posts. The query looks a mess. Align selects,froms,where...
How do you want to join them ? Is there a criteria?? Post sample data from query 2 like you did for query 1 and expected output as well.
Go to Top of Page

charul
Starting Member

18 Posts

Posted - 2009-03-19 : 07:45:58
Select 'ABC' as [col1]
JOIN

(
(Select 'PQR' [col2])
UNION
(Select 'XYZ' [col2])
)

say something like this possible?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-19 : 12:01:41
post the question in this format giving necessary info

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -