Click here to Skip to main content
15,747,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi dear Developers!
I want to select some records of Student from student Table that not appear in exam table e.g select that student that not in exam. if data found in exam then check that exist data with not same session and term if session is same them check is the term change if no then check class , is class change if class also same and all record math in exam then skip and select next one

this is my qurry
ALTER PROCEDURE [dbo].[usp_ExamGetStudentForInsertMarsk]
@Class	INT,
@Term	INT,
@Session	NVARCHAR(50)


					 ,[RegistrationNo] AS 'Reg.No' 
					,[FatherName] AS 'Fname'
					,lstC.Description 'Class'
			FROM [dbo].[Student] s
			LEFT JOIN [dbo].[ExamData] e 
			ON s.RegistrationNo = e.studentID
			left join [dbo].[ListTypesData] lstC 
			ON s.CurrentClass = lstC.ListTypeDataId
			WHERE CurrentClass = @Class
				AND (e.Term != @Term or e.Term is null)
				AND s.Session= @Session
				AND (s.IsLeft != 1 OR s.IsLeft IS NULL)

What I have tried:

I tried with Not in and also with != and
Also with sub qurries
Updated 25-Jul-22 2:58am

Share this answer
Fahim ullah 25-Jul-22 9:11am    
I check that bro.
Basically the record exist in exam table with different session and term.
But when i select examdata.term =! X the give me dataset of null terms
OriginalGriff 25-Jul-22 9:35am    
Do you want to try that again, in English? And SQL with examples of what you expected and got by preference?
Share this answer
Richard Deeming 25-Jul-22 10:43am    
The question is tagged as SQL Server, which does not support the MINUS operator.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900