Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Example 1
It is possible to have duplicate names. For example, if you do not select StudentContactType as SC1, you only pick up the primary contacts and not Term and Alternate as well. Otherwise, you would be returning one line for every contact that a student has.

Query with duplicate records

SELECT ID, StudentContactMailName, StudentContactAddressComma, StudentContactType
FROM vStudentContactAddress
WHERE CurrentSemesterOnlyFlag = 1

Returns

IDContactMailNameContactAddressContactType
364Mr Joe Black15 Green St, MT WAVERLEY VIC 3149SC1
364Mr Joe Black341 Flowerdale Ave, St Kilda VIC 3182SC2

Query with correction

SELECT ID, StudentContactMailName, StudentContactAddressComma, StudentContactType
FROM vStudentContactAddress, StudentContact
WHERE CurrentSemesterOnlyFlag = 1 AND NormalMailFlag = 1

Returns
IDContactMailNameContactAddressContactType
364Mr Joe Black15 Green St, MT WAVERLEY VIC 3149SC1


...

  • YearLevel field to the query
  • key word DISTINCT.

Query with correction
SELECT DISTINCT StudentContactMailName, StudentContactAddressComma, YearLevel
FROM vStudentContactAddress
WHERE StudentContactNormalMailFlag = 1 AND
CurrentSemesterOnlyFlag = 1
Returns
ContactMailNameContactAddressYearLevel
Mr Joe Black15 Green St, MT WAVERLEY VIC 31495
Mr Joe Black15 Green St, MT WAVERLEY VIC 314910