{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Week 9 - Advanced SQL Using and manipulating the data you...

Info icon This preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
9/9/2009 1 Advanced SQL Using and manipulating the data you stored Week 9 Checkpoint What we have learnt so far Why database design The tool for capturing business rules (ERD) Defining relations (normalization) Last session The SQL commands DDL and DML This session 7-2 More advanced DB operations
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
9/9/2009 2 Relational Set Operators UNION INTERSECT MINUS Work properly if relations are union- compatible Names of relation attributes must be the same and their data types must be identical 7-3 UNION Example query: SELECT CUS_LNAME, CUS_FNAME, CUS_INITIAL, CUS_AREACODE, CUS_PHONE FROM CUSTOMER UNION SELECT CUS_LNAME, CUS_FNAME, 7-4 CUS_INITIAL, CUS_AREACODE, CUS_PHONE FROM CUSTOMER_2;
Image of page 2
9/9/2009 3 UNION (cont’d) UNION query results: 7-5 UNION ALL Example query: SELECT CUS LNAME CUS FNAME CUS_LNAME, CUS_FNAME, CUS_INITIAL, CUS_AREACODE, CUS_PHONE FROM CUSTOMER UNION ALL SELECT CUS_LNAME, CUS_FNAME, CUS INITIAL CUS AREACODE 7-6 CUS_INITIAL, CUS_AREACODE, CUS_PHONE FROM CUSTOMER_2; (including duplicated rows!)
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
9/9/2009 4 UNION ALL (cont’d) UNION ALL query results: 7-7 INTERSECT 7-8
Image of page 4
9/9/2009 5 MINUS 7-9 SQL Functions l SQL functions are very useful tools l Some SQL functions Date and Time F nctions l Date and Time Functions l Numerical Functions l String Functions l Conversion Functions SELECT EMP LNAME YEAR(EMP DOB) AS YEAR 7-10 SELECT EMP_LNAME, YEAR(EMP_DOB) AS YEAR FROM EMPLOYEE WHERE YEAR(EMP_DOB) = 1952
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern