-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdml.sql
63 lines (47 loc) · 1.32 KB
/
dml.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
SELECT * FROM TBL_MEMBER;
SELECT * FROM TBL_BUSINESS;
SELECT * FROM TBL_SUPER_CAR;
SELECT * FROM TBL_BOARD;
SELECT * FROM TBL_REPLY;
SELECT * FROM TBL_PET;
SELECT * FROM TBL_OWNER;
SELECT * FROM TBL_FILE;
SELECT * FROM TBL_QUESTION;
SELECT * FROM TBL_ANSWER;
SELECT * FROM TBL_BOARD;
SELECT * FROM TBL_LIKE;
SELECT * FROM TBL_EMPLOYEE;
SELECT * FROM TBL_CAR;
SELECT * FROM TBL_CAR_OWNER;
SELECT * FROM TBL_CAR_REGISTRATION WHERE CAR_ID = 2349;
SELECT O.OWNER_NAME, COUNT(C.ID) FROM TBL_CAR_OWNER O JOIN TBL_CAR C
ON O.ID = C.CAR_OWNER_ID
GROUP BY O.OWNER_NAME;
SELECT B.ID, B.BOARD_TITLE, B.BOARD_CONTENT, COUNT(B.ID) LIKE_COUNT
FROM TBL_BOARD B LEFT OUTER JOIN TBL_LIKE L
ON B.ID = L.BOARD_ID
GROUP BY B.ID, B.BOARD_TITLE, B.BOARD_CONTENT;
SELECT ROWNUM R, B.* FROM TBL_BOARD B ORDER BY ROWNUM DESC;
SELECT BOARD.* FROM
(
SELECT ROWNUM R, B.* FROM TBL_BOARD B ORDER BY ROWNUM DESC
) BOARD
WHERE
R BETWEEN
(
SELECT R - 3 FROM
(
SELECT ROWNUM R, B.* FROM TBL_BOARD B ORDER BY ROWNUM DESC
)
WHERE ID = 1522
)
AND
(
SELECT R + 3 FROM
(
SELECT ROWNUM R, B.* FROM TBL_BOARD B ORDER BY ROWNUM DESC
)
WHERE ID = 1522
);
SELECT ID, PREV FROM (SELECT ID, LAG(ID) OVER(ORDER BY ID DESC) PREV FROM TBL_BOARD) WHERE ID = 1522;
SELECT ID, PREV FROM (SELECT ID, LEAD(ID) OVER(ORDER BY ID DESC) PREV FROM TBL_BOARD) WHERE ID = 1522;