瀏覽代碼

moved other one, started so far here

Jared Dunbar 2 年之前
父節點
當前提交
9781270d63
簽署人: Jared Dunbar <jrddunbr@gmail.com> GPG 金鑰 ID: CF202CC859BAC692
共有 2 個檔案被更改,包括 53 行新增0 行删除
  1. 0
    0
      10-31-18.sql
  2. 53
    0
      11-5-18.sql

inclass.sql → 10-31-18.sql 查看文件


+ 53
- 0
11-5-18.sql 查看文件

@@ -0,0 +1,53 @@
1
+-- in class examples
2
+
3
+-- first, always see the data you are working with
4
+SELECT * FROM employee
5
+
6
+-- then, see the size of the data
7
+SELECT COUNT(*) FROM employee
8
+
9
+-- show winners of the nobel prize in 1950
10
+SELECT yr, subject, winner FROM nobel
11
+WHERE yr = 1950
12
+
13
+-- show 1962 Literature prize winners
14
+SELECT winner
15
+FROM nobel
16
+WHERE yr = 1950
17
+AND subject = 'Literature'
18
+
19
+-- find nobel prizes that Albert Einstein won
20
+SELECT yr, subject
21
+FROM nobel
22
+WHERE winner = 'Albert Einstein'
23
+
24
+-- Peace winners since 2000 inclusively
25
+SELECT winner
26
+FROM nobel
27
+WHERE yr >= 2000
28
+AND subject = 'Peace'
29
+
30
+-- Good idea to show the criteria you are filtering on
31
+SELECT winner, yr
32
+FROM nobel
33
+WHERE yr >= 2000
34
+AND subject = 'Peace'
35
+
36
+-- Show all details (year, subject winner) of winners from 1980 to 1989 of he Literature prize
37
+SELECT *
38
+FROM nobel
39
+WHERE yr >= 1980
40
+AND yr <= 1989
41
+AND subject = 'Literature'
42
+
43
+-- use something other than two ands - LIKE works
44
+SELECT *
45
+FROM nobel
46
+WHERE yr LIKE '198%'
47
+AND subject = 'Literature'
48
+
49
+-- and we can also try this:
50
+SELECT *
51
+FROM nobel
52
+WHERE yr BETWEEN 1980 AND 1989 -- this is inclusively specified
53
+AND subject = 'Literature'

Loading…
取消
儲存