banner sql 201

Post on 11-May-2022

4 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Banner SQL 201

Georgia Summit 2013

Thursday, September 19th4:10pm - 5:00pm

Estes B

Zachary HayesAssociate Registrar

Georgia Institute of Technology

Monday, September 23, 13

Introduction• Who is this guy?

• 10 years within USG

• Self-taught SQL and Banner

• Where does he work?

• Banner 8.5 / Oracle 11g

• Enterprise Information Systems

• Technical Analysts, Developers, DBAs

• Office of the Registrar

• Business/Information Analysts,Assistant Registrar for Technology

2

Monday, September 23, 13

Disclaimer

• I am not an expert

• There may be better ways to do this

• Your user access may not permit table queries

• Your IT staff may not want to help you

• For ages 13+ contains small parts not suitable for children

3

Monday, September 23, 13

Agenda• Banner SQL 101 refresher

• Banner Oracle SQL

• Null Value

• Decode

• Left Join

• Exist

• Count / Group By / Having

• Questions4

Monday, September 23, 13

Data Dictionary• What are Banner tables and columns named?

• Banner Dynamic Help Query

• Within INB, click a field you want to get information on

• Select Help > Dynamic Help Query

• Popup will usually show you the column name from the database

• When in doubt, ask your technical staff

5

101

Monday, September 23, 13

Data Dictionary

6

101

Monday, September 23, 13

Data Dictionary

6

101

Monday, September 23, 13

Data Dictionary• Oracle Data Dictionary

• Read what Ellucian may have included in the Oracle Data Dictionary

• ALL_TAB_COMMENTS

• ALL_COL_COMMENTS

• Will need to query via a SQL tool (SQL*Plus, SQL Developer, Toad, etc)

• Will need access to query the database directly, and may need additional access to these views

• When in doubt, ask your technical staff

7

101

Monday, September 23, 13

Data Dictionary• ALL_COL_COMMENTS

8

101

Monday, September 23, 13

• PopSels are handy, but what if

• you need more data than just a student ID

• you need more than one subquery

• you need an outer join

• you need data outside of Banner’s standard schema (ex: DegreeWorks database)

• Roll up your sleeves, make friends with your IT staff, and query the tables directly!

• If you have mastered SQL within PopSels, you already have a solid foundation to work from

9

101 PopSel Limitations

Monday, September 23, 13

Banner Oracle SQL• one table, wild card value

10

101

Monday, September 23, 13

Banner Oracle SQL• two tables, date value

11

101

Monday, September 23, 13

Banner Oracle SQL• two tables, parameters, subquery

12

101

Monday, September 23, 13

Banner Oracle SQL• NVL (Null Value)

• Something that is null does not exist

• If something doesn’t exist, you can’t:

• display anything for it

• do any calculations against it

• NVL temporarily puts a value in when it is null

• This does not alter what is stored in the database

13

Monday, September 23, 13

NVL

14

Monday, September 23, 13

NVL

14

Monday, September 23, 13

NVL• Syntax:

• NVL(field, replace)

• For humans:

• If <field> is null, then temporarily insert the <replace> value

• If <field> is not null, then keep <field> value

• <replace> can be another field or your own value

15

Monday, September 23, 13

NVL• Example 1 (before)

16

Monday, September 23, 13

NVL• Example 1 (before)

16

Monday, September 23, 13

NVL• Example 1 (after)

17

Monday, September 23, 13

NVL• Example 1 (after)

17

Monday, September 23, 13

NVL• Example 1 (before and after)

18

Monday, September 23, 13

NVL• Example 1 (before and after)

18

Monday, September 23, 13

NVL• Example 2

19

Monday, September 23, 13

NVL• Example 2

19

Monday, September 23, 13

Banner Oracle SQL• Decode

• Similar to an IF - THEN - ELSE statement

• If you have values in the database that you want to temporarily massage/tweak for your query, decode will do the trick

• Great tool to make results easier for the end user as to compared to what may be under the hood of the database

• This does not alter what is stored in the database

20

Monday, September 23, 13

Decode

21

Monday, September 23, 13

Decode

21

Monday, September 23, 13

Decode• Syntax:

• DECODE(field, search1, replace1, search2, replace2, ... , default)

• For humans:

• If <field> matches <search1>, then temporarily replace the value with <replace1>

• If <field> matches <search2>, then temporarily replace the value with <replace2>

• If <field> doesn’t match any <search> value, then temporarily replace the value with <default>

22

Monday, September 23, 13

Decode• For humans (cont.):

• <search>, <replace>, and <default> can be another field or your own value

• <default> is optionalIf the <field> doesn’t match any <search> values and there is no <default> the result will be null

23

Monday, September 23, 13

Decode• Example 1

24

Monday, September 23, 13

Decode• Example 1

24

Monday, September 23, 13

Decode• Example 1

24

Monday, September 23, 13

FERPA

25

Monday, September 23, 13

FERPA

25

FERPAMonday, September 23, 13

Decode• Example 2

26

Monday, September 23, 13

Decode• Example 2

26

Monday, September 23, 13

Decode• Example 2

26

Monday, September 23, 13

Banner Oracle SQL• Simple Join (Inner Join)

• Joins two tables and shows results from both so long as the join condition between the two is met

27

101

BA

Monday, September 23, 13

Banner Oracle SQL• Left Join (Left Outer Join)

• Joins two tables and shows all results from the left and only those from the right where the join condition between the two is met

28

BA

Monday, September 23, 13

Left Join

29

Monday, September 23, 13

Left Join

29

Monday, September 23, 13

Left Join• Example 1

30

Monday, September 23, 13

Left Join• Example 1

30

Monday, September 23, 13

Left Join• Example 1

30

Monday, September 23, 13

Left Join• Example 1

30

Monday, September 23, 13

Left Join• Example 2

31

Monday, September 23, 13

Left Join• Example 2

31

Monday, September 23, 13

Left Join• Example 2

31

Monday, September 23, 13

Left Join• Example 2

31

Monday, September 23, 13

Banner Oracle SQL• Exists

• You might find a time where you don’t want to join two tables (which can limit your results) but instead you just need to know if a condition exists in another table

• Also have the option to determine if a condition does not exist

• Uses a standard subquery, but it only cares if at least one row is produced

32

Monday, September 23, 13

Exists• Zach is staying at the Double Tree Hotel. What

other hotel brands are related to this hotel?

33

Monday, September 23, 13

Exists• Zach is staying at the Double Tree Hotel. What

other hotel brands are related to this hotel?

33

Monday, September 23, 13

Exists• Syntax:

• EXISTS(select ‘T’ from ... where ...)

• For humans:

• So long as the subquery returns one row, the condition is met and the main query will continue

• NOT EXISTS will have the inverse result

34

Monday, September 23, 13

Exists• Example 1 (before)

35

Monday, September 23, 13

Exists• Example 1 (before)

35

Monday, September 23, 13

Exists• Example 1 (after)

36

Monday, September 23, 13

Exists• Example 1 (after)

36

Monday, September 23, 13

Exists• Example 1 (before and after)

37

Monday, September 23, 13

Exists• Example 1 (before and after)

37

Monday, September 23, 13

Exists• Example 2

38

Monday, September 23, 13

Exists• Example 2

38

Monday, September 23, 13

Banner Oracle SQL• Count / Group / Having

• You may not always want raw record data, but instead aggregate data that summarizes the data

• In order to aggregate data, you have to determine how the data should be grouped

• Once the data is grouped and aggregated, you might need to filter results to those that have met your condition

39

Monday, September 23, 13

Count / Group / Having1) How many kids by shirt color?

2) How many kids by sex?

3) How many kids by sex having >5?

40

Monday, September 23, 13

Count / Group / Having1) How many kids by shirt color?

2) How many kids by sex?

3) How many kids by sex having >5?

40

B = 7 ; G = 7

Monday, September 23, 13

Count / Group / Having1) How many kids by shirt color?

2) How many kids by sex?

3) How many kids by sex having >5?

40

B = 7 ; G = 7

F = 2 ; M = 12

Monday, September 23, 13

Count / Group / Having1) How many kids by shirt color?

2) How many kids by sex?

3) How many kids by sex having >5?

40

B = 7 ; G = 7

F = 2 ; M = 12

M = 12

Monday, September 23, 13

Count / Group / Having• Syntax:

• SELECT <field1>, count<values>FROM <table>WHERE ...GROUP BY <field1>HAVING count<values> <filter>

• For humans:

• Count <values> from <table> grouped by <field1> that have meet <filter> condition

• All SELECT fields must be in the GROUP BY

• HAVING is optional41

Monday, September 23, 13

Count / Group / Having• Example 1 (no Having)

42

Monday, September 23, 13

Count / Group / Having• Example 1 (no Having)

42

Monday, September 23, 13

Count / Group / Having• Example 1 (Having)

43

Monday, September 23, 13

Count / Group / Having• Example 1 (Having)

43

Monday, September 23, 13

Count / Group / Having• Example 2 (no Having)

44

Monday, September 23, 13

Count / Group / Having• Example 2 (no Having)

44

Monday, September 23, 13

Count / Group / Having• Example 2 (Having)

45

Monday, September 23, 13

Count / Group / Having• Example 2 (Having)

45

Monday, September 23, 13

NVL, Decode, Left Join, Exists, Count/Group/Having

46

Monday, September 23, 13

NVL, Decode, Left Join, Exists, Count/Group/Having

46

Monday, September 23, 13

Banner SQL 201

Questions?

Zachary Hayes

zachary.hayes@registrar.gatech.edu

47

Monday, September 23, 13

top related