banner sql 201

79
Banner SQL 201 Georgia Summit 2013 Thursday, September 19th 4:10pm - 5:00pm Estes B Zachary Hayes Associate Registrar Georgia Institute of Technology Monday, September 23, 13

Upload: others

Post on 11-May-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Banner SQL 201

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

Page 2: Banner SQL 201

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

Page 3: Banner SQL 201

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

Page 4: Banner SQL 201

Agenda• Banner SQL 101 refresher

• Banner Oracle SQL

• Null Value

• Decode

• Left Join

• Exist

• Count / Group By / Having

• Questions4

Monday, September 23, 13

Page 5: Banner SQL 201

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

Page 6: Banner SQL 201

Data Dictionary

6

101

Monday, September 23, 13

Page 7: Banner SQL 201

Data Dictionary

6

101

Monday, September 23, 13

Page 8: Banner SQL 201

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

Page 9: Banner SQL 201

Data Dictionary• ALL_COL_COMMENTS

8

101

Monday, September 23, 13

Page 10: Banner SQL 201

• 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

Page 11: Banner SQL 201

Banner Oracle SQL• one table, wild card value

10

101

Monday, September 23, 13

Page 12: Banner SQL 201

Banner Oracle SQL• two tables, date value

11

101

Monday, September 23, 13

Page 13: Banner SQL 201

Banner Oracle SQL• two tables, parameters, subquery

12

101

Monday, September 23, 13

Page 14: Banner SQL 201

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

Page 15: Banner SQL 201

NVL

14

Monday, September 23, 13

Page 16: Banner SQL 201

NVL

14

Monday, September 23, 13

Page 17: Banner SQL 201

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

Page 18: Banner SQL 201

NVL• Example 1 (before)

16

Monday, September 23, 13

Page 19: Banner SQL 201

NVL• Example 1 (before)

16

Monday, September 23, 13

Page 20: Banner SQL 201

NVL• Example 1 (after)

17

Monday, September 23, 13

Page 21: Banner SQL 201

NVL• Example 1 (after)

17

Monday, September 23, 13

Page 22: Banner SQL 201

NVL• Example 1 (before and after)

18

Monday, September 23, 13

Page 23: Banner SQL 201

NVL• Example 1 (before and after)

18

Monday, September 23, 13

Page 24: Banner SQL 201

NVL• Example 2

19

Monday, September 23, 13

Page 25: Banner SQL 201

NVL• Example 2

19

Monday, September 23, 13

Page 26: Banner SQL 201

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

Page 27: Banner SQL 201

Decode

21

Monday, September 23, 13

Page 28: Banner SQL 201

Decode

21

Monday, September 23, 13

Page 29: Banner SQL 201

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

Page 30: Banner SQL 201

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

Page 31: Banner SQL 201

Decode• Example 1

24

Monday, September 23, 13

Page 32: Banner SQL 201

Decode• Example 1

24

Monday, September 23, 13

Page 33: Banner SQL 201

Decode• Example 1

24

Monday, September 23, 13

Page 34: Banner SQL 201

FERPA

25

Monday, September 23, 13

Page 35: Banner SQL 201

FERPA

25

FERPAMonday, September 23, 13

Page 36: Banner SQL 201

Decode• Example 2

26

Monday, September 23, 13

Page 37: Banner SQL 201

Decode• Example 2

26

Monday, September 23, 13

Page 38: Banner SQL 201

Decode• Example 2

26

Monday, September 23, 13

Page 39: Banner SQL 201

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

Page 40: Banner SQL 201

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

Page 41: Banner SQL 201

Left Join

29

Monday, September 23, 13

Page 42: Banner SQL 201

Left Join

29

Monday, September 23, 13

Page 43: Banner SQL 201

Left Join• Example 1

30

Monday, September 23, 13

Page 44: Banner SQL 201

Left Join• Example 1

30

Monday, September 23, 13

Page 45: Banner SQL 201

Left Join• Example 1

30

Monday, September 23, 13

Page 46: Banner SQL 201

Left Join• Example 1

30

Monday, September 23, 13

Page 47: Banner SQL 201

Left Join• Example 2

31

Monday, September 23, 13

Page 48: Banner SQL 201

Left Join• Example 2

31

Monday, September 23, 13

Page 49: Banner SQL 201

Left Join• Example 2

31

Monday, September 23, 13

Page 50: Banner SQL 201

Left Join• Example 2

31

Monday, September 23, 13

Page 51: Banner SQL 201

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

Page 52: Banner SQL 201

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

other hotel brands are related to this hotel?

33

Monday, September 23, 13

Page 53: Banner SQL 201

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

other hotel brands are related to this hotel?

33

Monday, September 23, 13

Page 54: Banner SQL 201

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

Page 55: Banner SQL 201

Exists• Example 1 (before)

35

Monday, September 23, 13

Page 56: Banner SQL 201

Exists• Example 1 (before)

35

Monday, September 23, 13

Page 57: Banner SQL 201

Exists• Example 1 (after)

36

Monday, September 23, 13

Page 58: Banner SQL 201

Exists• Example 1 (after)

36

Monday, September 23, 13

Page 59: Banner SQL 201

Exists• Example 1 (before and after)

37

Monday, September 23, 13

Page 60: Banner SQL 201

Exists• Example 1 (before and after)

37

Monday, September 23, 13

Page 61: Banner SQL 201

Exists• Example 2

38

Monday, September 23, 13

Page 62: Banner SQL 201

Exists• Example 2

38

Monday, September 23, 13

Page 63: Banner SQL 201

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

Page 64: Banner SQL 201

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

Page 65: Banner SQL 201

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

Page 66: Banner SQL 201

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

Page 67: Banner SQL 201

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

Page 68: Banner SQL 201

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

Page 69: Banner SQL 201

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

42

Monday, September 23, 13

Page 70: Banner SQL 201

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

42

Monday, September 23, 13

Page 71: Banner SQL 201

Count / Group / Having• Example 1 (Having)

43

Monday, September 23, 13

Page 72: Banner SQL 201

Count / Group / Having• Example 1 (Having)

43

Monday, September 23, 13

Page 73: Banner SQL 201

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

44

Monday, September 23, 13

Page 74: Banner SQL 201

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

44

Monday, September 23, 13

Page 75: Banner SQL 201

Count / Group / Having• Example 2 (Having)

45

Monday, September 23, 13

Page 76: Banner SQL 201

Count / Group / Having• Example 2 (Having)

45

Monday, September 23, 13

Page 77: Banner SQL 201

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

46

Monday, September 23, 13

Page 78: Banner SQL 201

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

46

Monday, September 23, 13

Page 79: Banner SQL 201

Banner SQL 201

Questions?

Zachary Hayes

[email protected]

47

Monday, September 23, 13