How to create a query according to the students? I tried it like this, but I probably need it as something different.

SELECT [SSN]      ,[Studentnumber]      ,[Surename]      ,[Forenames]      ,[Bithdate]      ,[Address]      ,[Phonenumber] FROM [dw].[connected_person_contact_details] Where (Surename IS NULL OR Surename = @Surename) AND (SSN IS NULL OR SSN = @SSN) AND (Phonenumber IS NULL OR Phonenumber = @Phonenumber) 

It is necessary to do a search for example in one of the above parameters. Or such a query so that you can search by one or more parameters.

  • one
    why don't you like the current implementation? in my opinion everything is logical - Xramovnic
  • it is not a field that is needed, but a variable with NULL sorted in order to search for a given parameter. @surname IS NULL etc. - teran

1 answer 1

 SELECT [SSN] ,[Studentnumber] ,[Surename] ,[Forenames] ,[Bithdate] ,[Address] ,[Phonenumber] FROM [dw].[connected_person_contact_details] Where (@Surename IS NULL OR Surename = @Surename) AND (@SSN IS NULL OR SSN = @SSN) AND (@Phonenumber IS NULL OR Phonenumber = @Phonenumber)