| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Creating Complex Views for Reporting

Page history last edited by Dr. Ron Eaglin 15 years, 3 months ago

Creating Complex Views for Reporting

 

Pre-Requisites

 Spring 2008 Assignment 2 Review 

 

 

Download Link 

 

SQL View Creation Code

This code goes with the Spring 2008 Assignment series at  Assignment Assistance


Drop View StudentView
GO

CREATE VIEW StudentView AS
SELECT s.StudentID as 'Student ID',
      dbo.PersonName.PersonSurNameText as 'First Name', 
      dbo.PersonName.PersonGivenNameText as 'Last Name',
      dbo.ContactInformation.EmailIDText as 'E-Mail', 
      dbo.ContactInformation.MobileTelephoneNumberText as 'Cell Phone', 
      dbo.ContactInformation.TelephoneNumberText as 'Home Phone',   
       
      (SELECT  dbo.Address.AddressText 
           FROM dbo.Address, dbo.ContactInformation, dbo.Student
           WHERE dbo.Student.StudentID = s.StudentID
             AND dbo.ContactInformation.PersonContactInformationID = dbo.Student.StudentContactInformationID
             AND dbo.ContactInformation.PersonHomeAddressID = dbo.Address.AddressID) as 'Home Address',
     
      (SELECT  dbo.Address.AddressText 
           FROM dbo.Address, dbo.ContactInformation, dbo.Student
           WHERE dbo.Student.StudentID = s.StudentID
             AND dbo.ContactInformation.PersonContactInformationID = dbo.Student.StudentContactInformationID
             AND dbo.ContactInformation.PersonCurrentAddressID = dbo.Address.AddressID) as 'Current Address'

 FROM dbo.Student s
      
      INNER JOIN dbo.PersonName
      ON s.StudentNameID = dbo.PersonName.NameID

      INNER JOIN dbo.ContactInformation
      ON s.StudentContactInformationID = dbo.ContactInformation.PersonContactInformationID

GO

SELECT * FROM StudentView

Comments (0)

You don't have permission to comment on this page.