I wrote the following query to fetch the rows from examPeriod
that match rows inside EXAMCENTERWORKINGDAYS
based on the condition Eep.[tpId]=ecwd.[TRAININGPERIODID]
The query is as follows:
SELECT ep.[id]
FROM [LMS17_ARU_backup_201402080000].[dbo].[examperiod]ep
RIGHT JOIN
(SELECT ecwd.[trainingperiodid]
FROM [LMS17_ARU_backup_201402080000].[dbo].[examcenterworkingdays]ecwd
WHERE ecwd.[value] <> 0
AND ecwd.[trainingperiodid]IS NOT NULL)ecwd ON ep.[tpid] = ecwd.[trainingperiodid]
The trouble is that the select statement inside the bracket after the right join
retrieves only 95 rows and when I execute the query it returns 324 rows. I expected all the queries to return 95 rows, i.e I want to get ep.[id]
from [examPeriod]
table from the 95 rows returned from the nested select when ep.[tpId]=ecwd.[TRAININGPERIODID]
Sorry if it was silly question