-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQL
More file actions
30 lines (18 loc) · 737 Bytes
/
SQL
File metadata and controls
30 lines (18 loc) · 737 Bytes
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
-- שליפת משתמשים ופוסטים פעילים
SELECT Users.id, Users.name, Users.email, Users.active, Posts.title, Posts.creation_date
FROM Users
JOIN Posts ON Users.id = Posts.user_id
WHERE Users.active = 1 AND Posts.active = 1;
-- מציאת הפוסט האחרון ליוזר עם יומולת בחודש הנוכחי
SELECT Users.name, MAX(Posts.creation_date) AS last_post_date
FROM Users
JOIN Posts ON Users.id = Posts.user_id
WHERE Users.birthdate IS NOT NULL
AND MONTH(Users.birthdate) = MONTH(NOW())
GROUP BY Users.name;
CREATE DATABASE IF NOT EXISTS INMANGE;
-- יצירת טבלה עביר כמה פוסטים לכל שעה
CREATE TABLE PostsPerHour (
post_hour DATETIME,
post_count INT
);