Skip to main content

ACS Workshop (SQL)

Question 1 (Create,Insert)

1.1 CREATE TABLE และ กำหนด id เป็น primary key

CREATE TABLE employees (
  id INT,
  name TEXT,
  salary REAL,
  job TEXT,
  --INPUT CODE HERE 
);

1.2 ใช้คำสั่ง INSERT data เพื่อใส่ข้อมูลเข้าไปใน table employees และ ใส่ข้อมูลของตัวเองลงไปตามตัวอย่าง

INSERT INTO employees (id, name, salary, job) VALUES
  (1, 'Lalita Suriya', 25000, 'Developer'),
  (2, 'Somsak Somporn', 42500, 'UX/UI Designer'),
  (3, 'Siriporn Amporn', 35000, 'Developer'),
  (4, 'alita Somsak', 50000, 'UX/UI Designer'),
  (5, 'Preecha Kamon', 55000, 'Frontend Developer'),
  (6, 'Preecha Kanya', 27500, 'Backend Developer'),
  (7, 'Somporn Thaksin', 30000, 'UX/UI Designer'),
  (8, 'Sunan Intira', 20000, 'Frontend Developer'),
  (9, 'Kanda Ratree', 23500, 'Developer'),
  (10, 'Klahan Suchart', 20000, 'Fullstack Developer'),
  (11, 'Sukhon Intira', 60000, 'Data scientist'),
  (12, 'Wattana Somboon', 30000, 'Data analytics'),
  (13, 'Lalita Thaksin', 55000, 'DevOps'),
  (14, 'Somchai Malai', 43500, 'Data analytics'),
  (15, 'Mali Amporn', 60000, 'Developer'),
  (16, 'Pranee Porntip', 25000, 'DevOps'),
  (17, ' Somporn Prasert', 35000, 'Web Developer'),
  (18, 'Mongkut Arum', 20000, 'Frontend Developer'),
  (19, 'Pranee Wattana', 45000, 'Backend Developer');
  
  INSERT INTO employees (id, name, salary, job) VALUES
  --ใส่ข้อมูลของตัวเอง ex. (1, 'Teacher', 25000, 'Student')

Question 2 (UPDATE)

ให้ทำการ อัปเดตข้อมูล job จาก DevOps เป็น DevOps Engineer

UPDATE  ____  ___  job = 'DevOps Engineer'  ____ job = 'DevOps';
SELECT * FROM _____;

OUTPUT:

image.png


Question 3 (Delete)

จงลบข้อมูล job ทีมีค่าเท่ากับ 'UX/UI Designer'

DELETE FROM ___ WHERE ___ = "UX/UI Designer";
SELECT * FROM ___ where ___ = "UX/UI Designer";

OUTPUT:

image.png


Question  4 (Select)

                 Question 4.1 (Where)

ให้แสดงข้อมูลออกมาตามเงื่อนไขดังนี้

SELECT * FROM ____ ____ ____ > 50000 or ____ = 'Developer' order by job ;

OUTPUT:

image.png

                 Question 4.2.1 (Order by)

จงแสดงข้อมูลจากน้อยไปมากโดยใช้ salary เป็นเกณฑ์  Hint: ASC

SELECT * FROM ____ ORDER BY ___ ___;

OUTPUT:

image.png

จงแสดงข้อมูลจากน้อยไปมากโดยใช้ salary เป็นเกณฑ์  Hint: DESC

SELECT * FROM ____ ORDER BY ___ ___;

OUTPUT:

image.png
                 Question 4.3 (Like)

ให้แสดงชื่อที่ขึ้นต้นด้วยตัว S%

จงแสดงข้อมูล ทั้งหมดที่มี name ขึ้นต้นด้วยตัว S  Hint: S% 

SELECT * FROM ___ WHERE ___ LIKE ___ ; 

OUTPUT:

image.png

                 Question 4.4 (Operator)

ให้แสดงข้อมูลทั้งหมด โดยมีเงื่อนไขว่าเป็นคนที่ salary > 30000 และ job = 'developer'

SELECT * FROM ____ where ____ > 30000 ____ ____ = 'Developer';

image.png

Question 5 (debug)

       เขียนโปรแกรมเพื่อหาข้อมูลที่ซ้ำกัน แก้ไขข้อมูล และกำหนด primary key


1.สร้าง table จาก data นี

CREATE TABLE Salary_Data_Random_Samples (id INT,
                                           Age INT,
                                           Gender TEXT,
                                           Education_Level TEXT,
                                           Job_Title TEXT,
                                           Years_of_Experience' TEXT,
                                           Salary INTEGER
                                          -- PRIMARY key (id)
                                          );
INSERT INTO 'Salary_Data_Random_Samples' ('id','Age','Gender','Education_Level','Job_Title','Years_of_Experience','Salary') VALUES 
 ('00163','28','Female','Bachelor''s','Software Engineer','5','160000'), 
 ('00162','27','Female','Bachelor''s Degree','Software Engineer','3','70000'), 
 ('00189','28','Male','Bachelor''s Degree','Web Developer','3','55000'), 
 ('00074','25','Female','Bachelor''s Degree','Junior Software Developer','S','35000'), 
 ('00177','54','Male','PhD','Software Engineer Manager','16','190000'), 
 ('00078','33','Male','Bachelor''s','Junior Software Developer','5','50000'), 
 ('00065','27','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00166','27','Female','Bachelor''s Degree','Software Engineer','3','70000'), 
 ('00085','27','Female','Bachelor''s Degree','Junior Software Engineer','1','45000'), 
 ('00147','45','Female','PhD','Senior UX Designer','16','160000'), 
 ('00103','30','Male','Bachelor''s','Network Engineer','3','60000'), 
 ('00139','54','Male','Master''s Degree','Senior Software Engineer','32','195270'), 
 ('00178','54','Female','PhD','Software Engineer Manager','32','191510'), 
 ('00132','38','Female','Bachelor''s','Senior Project Manager','9','120000'), 
 ('00146','40','Female','PhD','Senior Software Engineer','12','160000'), 
 ('00081','26','Female','Bachelor''s Degree','Junior Software Developer','2','35000'), 
 ('00066','27','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00107','45','Male','PhD','Senior Data Engineer','16','150000'), 
 ('00058','36','Male','Master''s Degree','Full Stack Engineer','11','137775'), 
 ('00117','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00019','25','Female','Master''s','Data Analyst','1','100000'), 
 ('00123','41','Female','Master''s Degree','Senior Project Engineer','11','165000'), 
 ('00007','38','Male','Bachelor''s Degree','Back end Developer','14','136449'), 
 ('00109','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00012','37','Male','Bachelor''s Degree','Data Analyst','11','160000'), 
 ('00063','28','Male','Bachelor''s Degree','Graphic Designer','3','60000'), 
 ('00136','34','Male','Master''s','Senior Software Developer','8','105000'), 
 ('00098','23','Female','Bachelor''s Degree','Junior Web Developer','1','40000'), 
 ('00069','27','Male','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00025','33','Male','PhD','Data Scientist','8','190000'), 
 ('00131','42','Female','Bachelor''s','Senior Project Manager','12','120000'), 
 ('00184','33','Male','Bachelor''s Degree','Web Developer','5','70000'), 
 ('00144','36','Male','Master''s Degree','Senior Software Engineer','7','140000'), 
 ('00141','37','Male','Master''s Degree','Senior Software Engineer','9','145000'), 
 ('00006','46','Female','Bachelor''s Degree','Back end Developer','18','155795'), 
 ('00158','28','Male','Bachelor''s Degree','Software Developer','3','60000'), 
 ('00093','34','Male','Bachelor''s Degree','Junior Web Developer','3','50000'), 
 ('00035','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00122','43','Male','PhD','Senior Project Engineer','13','185000'), 
 ('00154','24','Female','Bachelor''s Degree','Software Developer','2','55000'), 
 ('00037','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00015','30','Female','Bachelor''s','Data Analyst','5','145000'), 
 ('00070','26','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00095','34','Male','Bachelor''s Degree','Junior Web Developer','3','50000'), 
 ('00038','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00068','26','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00114','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00051','38','Male','Bachelor''s Degree','Front end Developer','11','136062'), 
 ('00088','26','Female','Bachelor''s Degree','Junior Software Engineer','1','45000'), 
 ('00191','36','Female','Master''s Degree','Web Developer','7','85000'), 
 ('00099','24','Female','Bachelor''s Degree','Junior Web Developer','1','40000'), 
 ('00018','26','Male','Bachelor''s','Data Analyst','3','120000'), 
 ('00094','32','Male','Bachelor''s Degree','Junior Web Developer','2','45000'), 
 ('00143','42','Male','PhD','Senior Software Engineer','14','170000'), 
 ('00040','25','Male','Bachelor''s Degree','Front End Developer','2','50000'), 
 ('00130','39','Female','Bachelor''s','Senior Project Manager','12','130000'), 
 ('00017','25','Female','Bachelor''s','Data Analyst','2','110000'), 
 ('00153','29','Male','Bachelor''s Degree','Software Developer','5','80000'), 
 ('00174','54','Male','PhD','Software Engineer Manager','17','195000'), 
 ('00009','36','Male','Master''s Degree','Back end Developer','9','150000'), 
 ('00086','27','Female','Bachelor''s Degree','Junior Software Engineer','2','48000'), 
 ('00057','25','Other','High School','Full Stack Engineer','2','69032'), 
 ('00031','27','Male','PhD','Developer','7','100000'), 
 ('00060','29','Female','Bachelor''s Degree','Full Stack Engineer','6','103579'), 
 ('00073','25','Female','Bachelor''s Degree','Junior Software Developer','1','35000'), 
 ('00047','30','Female','Master''s Degree','Front end Developer','5','105000'), 
 ('00186','27','Female','Bachelor''s Degree','Web Developer','2','50000'), 
 ('00021','32','Female','PhD','Data Scientist','9','145000'), 
 ('00124','47','Male','PhD','Senior Project Engineer','16','190000'), 
 ('00140','44','Male','Master''s Degree','Senior Software Engineer','18','152168'), 
 ('00028','31','Male','Master''s','Data Scientist','9','195000'), 
 ('00113','33','Male','Master''s Degree','Senior Data Scientist','8','120000'), 
 ('00112','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00089','25','Male','Bachelor''s Degree','Junior Software Engineer','1','55000'), 
 ('00142','46','Male','Master''s Degree','Senior Software Engineer','20','174938'), 
 ('00090','27','Female','Bachelor''s Degree','Junior Software Engineer','2','48000'), 
 ('00062','26','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00179','37','Female','Master''s','Software Manager','11','110000'), 
 ('00127','43','Male','PhD','Senior Project Engineer','13','185000'), 
 ('00014','31','Male','Bachelor''s','Data Analyst','9','195000'), 
 ('00039','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00108','44','Female','PhD','Senior Data Engineer','16','160000'), 
 ('00033','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00046','29','Male','Bachelor''s Degree','Front end Developer','3','80000'), 
 ('00148','45','Female','PhD','Senior UX Designer','16','160000'), 
 ('00168','28','Male','Bachelor''s Degree','Software Engineer','4','75000'), 
 ('00032','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00145','31','Female','Bachelor''s Degree','Senior Software Engineer','6','104378'), 
 ('00029','31','Female','PhD','Data Scientist','8','140000'), 
 ('00004','24','Male','Bachelor''s Degree','Back end Developer','1','55000'), 
 ('00100','26','Female','Bachelor''s Degree','Junior Web Developer','2','45000'), 
 ('00135','46','Male','PhD','Senior Researcher','18','150000'), 
 ('00056','27','Female','Master''s Degree','Full Stack Engineer','3','100000'), 
 ('00165','23','Female','Bachelor''s Degree','Software Engineer','1','50000'), 
 ('00048','25','Female','Bachelor''s Degree','Front end Developer','1','55000'), 
 ('00011','29','Female','Bachelor''s','Data Analyst','7','130000'), 
 ('00054','33','Female','Bachelor''s Degree','Full Stack Engineer','6','115000'), 
 ('00092','29','Male','Bachelor''s','Junior Web Designer','3','45000'), 
 ('00052','26','Male','Master''s Degree','Full Stack Engineer','4','102859'), 
 ('00042','26','Male','Master''s Degree','Front end Developer','3','73640'), 
 ('00160','30','Male','Bachelor''s Degree','Software Engineer','4','65000'), 
 ('00061','29','Male','Bachelor''s Degree','Full Stack Engineer','4','90000'), 
 ('00013','25','Male','Bachelor''s','Data Analyst','2','115000'), 
 ('00138','54','Other','High School','Senior Software Engineer','29','158966'), 
 ('00102','26','Female','Bachelor''s Degree','Junior Web Developer','2','45000'), 
 ('00134','46','Male','Master''s','Senior Project Manager','19','140000'), 
 ('00128','45','Male','PhD','Senior Project Engineer','16','185000'), 
 ('00036','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00172','45','Male','PhD','Software Engineer Manager','16','185000'), 
 ('00097','34','Male','Bachelor''s Degree','Junior Web Developer','3','50000'), 
 ('00118','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00001','29','Female','Master''s Degree','Back end Developer','3','90000'), 
 ('00072','26','Female','Bachelor''s Degree','Junior Software Developer','1','35000'), 
 ('00075','26','Female','Bachelor''s Degree','Junior Software Developer','2','35000'), 
 ('00091','25','Male','Bachelor''s Degree','Junior Software Engineer','1','55000'), 
 ('00076','28','Female','Bachelor''s Degree','Junior Software Developer','2','36000'), 
 ('00164','27','Female','Bachelor''s Degree','Software Engineer','3','70000'), 
 ('00111','47','Male','PhD','Senior Data Scientist','21','180000'), 
 ('00044','25','Female','Bachelor''s Degree','Front end Developer','1','55000'), 
 ('00053','28','Male','Master''s Degree','Full Stack Engineer','4','90452'), 
 ('00133','46','Male','Master''s','Senior Project Manager','21','135000'), 
 ('00096','24','Female','Bachelor''s Degree','Junior Web Developer','1','40000'), 
 ('00175','40','Male','Master''s Degree','Software Engineer Manager','16','150301'), 
 ('00121','47','Male','PhD','Senior Project Engineer','16','190000'), 
 ('00023','29','Female','Master''s','Data Scientist','6','180000'), 
 ('00022','30','Female','PhD','Data Scientist','7','170000'), 
 ('00002','38','Male','Bachelor''s Degree','Back end Developer','14','136449'), 
 ('00049','31','Female','Bachelor''s Degree','Front end Developer','6','110000'), 
 ('00188','24','Female','Bachelor''s Degree','Web Developer','1','40000'), 
 ('00079','28','Female','Bachelor''s Degree','Junior Software Developer','2','36000'), 
 ('00159','25','Female','Master''s Degree','Software Engineer','2','60000'), 
 ('00181','34','Female','Master''s','UX Designer','5','80000'), 
 ('00169','42','Male','Master''s Degree','Software Engineer Manager','13','170000'), 
 ('00120','43','Male','PhD','Senior Project Engineer','13','185000'), 
 ('00190','33','Male','Bachelor''s Degree','Web Developer','5','70000'), 
 ('00003','42','Male','Bachelor''s Degree','Back end Developer','16','137489'), 
 ('00182','28','Male','Master''s Degree','Web Developer','3','55000'), 
 ('00152','31','Male','Bachelor''s Degree','Software Developer','6','85000'), 
 ('00034','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00105','44','Female','PhD','Senior Data Engineer','16','160000'), 
 ('00055','33','Female','Master''s Degree','Full Stack Engineer','9','136986'), 
 ('00084','27','Male','Bachelor''s Degree','Junior Software Engineer','1','55000'), 
 ('00045','23','Male','High School','Front end Developer','1','47898'), 
 ('00050','28','Female','Bachelor''s Degree','Front end Developer','2','65000'), 
 ('00161','27','Male','Bachelor''s Degree','Software Engineer','3','80000'), 
 ('00080','28','Female','Bachelor''s Degree','Junior Software Developer','2','37000'), 
 ('00167','24','Male','Bachelor''s Degree','Software Engineer','2','55000'), 
 ('00115','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00150','27','Male','Bachelor''s Degree','Software Developer','1','50000'), 
 ('00125','32','Male','Master''s Degree','Senior Project Engineer','11','128078'), 
 ('00010','23','Female','High School','Back end Developer','1','52807'), 
 ('00041','29','Male','Bachelor''s Degree','Front End Developer','3','70000'), 
 ('00129','41','Male','PhD','Senior Project Engineer','13','185000'), 
 ('00026','28','Female','PhD','Data Scientist','5','100000'), 
 ('00156','26','Male','Bachelor''s Degree','Software Developer','2','60000'), 
 ('00101','29','Male','Bachelor''s Degree','Junior Web Developer','2','45000'), 
 ('00155','24','Female','Bachelor''s Degree','Software Developer','2','55000'), 
 ('00170','54','Male','PhD','Software Engineer Manager','17','195000'), 
 ('00151','29','Female','Master''s Degree','Software Developer','5','70000'), 
 ('00119','42','Female','Master''s','Senior Graphic Designer','15','110000'), 
 ('00187','34','Male','Bachelor''s Degree','Web Developer','4','65000'), 
 ('00116','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00043','28','Female','Bachelor''s Degree','Front end Developer','3','80000'), 
 ('00027','32','Female','PhD','Data Scientist','9','145000'), 
 ('00106','45','Male','PhD','Senior Data Engineer','16','150000'), 
 ('00176','52','Male','PhD','Software Engineer Manager','27','190596'), 
 ('00087','25','Male','Bachelor''s Degree','Junior Software Engineer','1','55000'), 
 ('00077','26','Female','Bachelor''s Degree','Junior Software Developer','2','35000'), 
 ('00024','31','Male','Master''s','Data Scientist','9','185000'), 
 ('00030','32','Female','PhD','Data Scientist','9','145000'), 
 ('00008','46','Female','Bachelor''s Degree','Back end Developer','19','150729'), 
 ('00067','27','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00064','27','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00071','27','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00183','32','Male','Master''s Degree','Web Developer','6','80000'), 
 ('00149','29','Male','Bachelor''s Degree','Software Developer','5','80000'), 
 ('00059','49','Male','Bachelor''s Degree','Full Stack Engineer','22','181132'), 
 ('00171','46','Female','PhD','Software Engineer Manager','14','180000'), 
 ('00126','45','Male','PhD','Senior Project Engineer','16','185000'), 
 ('00180','37','Male','Bachelor''s','Software Project Manager','9','95000'), 
 ('00110','33','Male','Master''s Degree','Senior Data Scientist','8','120000'), 
 ('00157','24','Female','Bachelor''s Degree','Software Developer','2','55000'), 
 ('00020','26','Male','Bachelor''s','Data Analyst','3','130000'), 
 ('00137','46','Male','Bachelor''s Degree','Senior Software Engineer','22','174324'), 
 ('00104','46','Male','PhD','Senior Data Analyst','17','160000'), 
 ('00082','26','Female','Bachelor''s Degree','Junior Software Engineer','1','45000'), 
 ('00016','35','Female','Master''s Degree','Data Analyst','9','120000'), 
 ('00083','27','Female','Bachelor''s Degree','Junior Software Engineer','2','48000'), 
 ('00005','26','Male','Bachelor''s Degree','Back end Developer','2','63789'), 
 ('00173','42','Male','Master''s Degree','Software Engineer Manager','13','170000'), 
 ('00185','33','Male','Bachelor''s Degree','Web Developer','5','70000');

CREATE TABLE Salary_Data_Random_Samples (id INT,
                                           Age INT,
                                           Gender TEXT,
                                           Education_Level TEXT,
                                           Job_Title TEXT,
                                           Years_of_Experience' TEXT,
                                           Salary INTEGER
                                          -- PRIMARY key (id)
                                          );
INSERT INTO 'Salary_Data_Random_Samples' ('id','Age','Gender','Education_Level','Job_Title','Years_of_Experience','Salary') VALUES 
 ('00163','28','Female','Bachelor''s','Software Engineer','5','160000'), 
 ('00162','27','Female','Bachelor''s Degree','Software Engineer','3','70000'), 
 ('00189','28','Male','Bachelor''s Degree','Web Developer','3','55000'), 
 ('00074','25','Female','Bachelor''s Degree','Junior Software Developer','S','35000'), 
 ('00177','54','Male','PhD','Software Engineer Manager','16','190000'), 
 ('00078','33','Male','Bachelor''s','Junior Software Developer','5','50000'), 
 ('00065','27','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00166','27','Female','Bachelor''s Degree','Software Engineer','3','70000'), 
 ('00085','27','Female','Bachelor''s Degree','Junior Software Engineer','1','45000'), 
 ('00147','45','Female','PhD','Senior UX Designer','16','160000'), 
 ('00103','30','Male','Bachelor''s','Network Engineer','3','60000'), 
 ('00139','54','Male','Master''s Degree','Senior Software Engineer','32','195270'), 
 ('00178','54','Female','PhD','Software Engineer Manager','32','191510'), 
 ('00132','38','Female','Bachelor''s','Senior Project Manager','9','120000'), 
 ('00146','40','Female','PhD','Senior Software Engineer','12','160000'), 
 ('00081','26','Female','Bachelor''s Degree','Junior Software Developer','2','35000'), 
 ('00066','27','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00107','45','Male','PhD','Senior Data Engineer','16','150000'), 
 ('00058','36','Male','Master''s Degree','Full Stack Engineer','11','137775'), 
 ('00117','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00019','25','Female','Master''s','Data Analyst','1','100000'), 
 ('00123','41','Female','Master''s Degree','Senior Project Engineer','11','165000'), 
 ('00007','38','Male','Bachelor''s Degree','Back end Developer','14','136449'), 
 ('00109','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00012','37','Male','Bachelor''s Degree','Data Analyst','11','160000'), 
 ('00063','28','Male','Bachelor''s Degree','Graphic Designer','3','60000'), 
 ('00136','34','Male','Master''s','Senior Software Developer','8','105000'), 
 ('00098','23','Female','Bachelor''s Degree','Junior Web Developer','1','40000'), 
 ('00069','27','Male','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00025','33','Male','PhD','Data Scientist','8','190000'), 
 ('00131','42','Female','Bachelor''s','Senior Project Manager','12','120000'), 
 ('00184','33','Male','Bachelor''s Degree','Web Developer','5','70000'), 
 ('00144','36','Male','Master''s Degree','Senior Software Engineer','7','140000'), 
 ('00141','37','Male','Master''s Degree','Senior Software Engineer','9','145000'), 
 ('00006','46','Female','Bachelor''s Degree','Back end Developer','18','155795'), 
 ('00158','28','Male','Bachelor''s Degree','Software Developer','3','60000'), 
 ('00093','34','Male','Bachelor''s Degree','Junior Web Developer','3','50000'), 
 ('00035','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00122','43','Male','PhD','Senior Project Engineer','13','185000'), 
 ('00154','24','Female','Bachelor''s Degree','Software Developer','2','55000'), 
 ('00037','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00015','30','Female','Bachelor''s','Data Analyst','5','145000'), 
 ('00070','26','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00095','34','Male','Bachelor''s Degree','Junior Web Developer','3','50000'), 
 ('00038','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00068','26','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00114','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00051','38','Male','Bachelor''s Degree','Front end Developer','11','136062'), 
 ('00088','26','Female','Bachelor''s Degree','Junior Software Engineer','1','45000'), 
 ('00191','36','Female','Master''s Degree','Web Developer','7','85000'), 
 ('00099','24','Female','Bachelor''s Degree','Junior Web Developer','1','40000'), 
 ('00018','26','Male','Bachelor''s','Data Analyst','3','120000'), 
 ('00094','32','Male','Bachelor''s Degree','Junior Web Developer','2','45000'), 
 ('00143','42','Male','PhD','Senior Software Engineer','14','170000'), 
 ('00040','25','Male','Bachelor''s Degree','Front End Developer','2','50000'), 
 ('00130','39','Female','Bachelor''s','Senior Project Manager','12','130000'), 
 ('00017','25','Female','Bachelor''s','Data Analyst','2','110000'), 
 ('00153','29','Male','Bachelor''s Degree','Software Developer','5','80000'), 
 ('00174','54','Male','PhD','Software Engineer Manager','17','195000'), 
 ('00009','36','Male','Master''s Degree','Back end Developer','9','150000'), 
 ('00086','27','Female','Bachelor''s Degree','Junior Software Engineer','2','48000'), 
 ('00057','25','Other','High School','Full Stack Engineer','2','69032'), 
 ('00031','27','Male','PhD','Developer','7','100000'), 
 ('00060','29','Female','Bachelor''s Degree','Full Stack Engineer','6','103579'), 
 ('00073','25','Female','Bachelor''s Degree','Junior Software Developer','1','35000'), 
 ('00047','30','Female','Master''s Degree','Front end Developer','5','105000'), 
 ('00186','27','Female','Bachelor''s Degree','Web Developer','2','50000'), 
 ('00021','32','Female','PhD','Data Scientist','9','145000'), 
 ('00124','47','Male','PhD','Senior Project Engineer','16','190000'), 
 ('00140','44','Male','Master''s Degree','Senior Software Engineer','18','152168'), 
 ('00028','31','Male','Master''s','Data Scientist','9','195000'), 
 ('00113','33','Male','Master''s Degree','Senior Data Scientist','8','120000'), 
 ('00112','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00089','25','Male','Bachelor''s Degree','Junior Software Engineer','1','55000'), 
 ('00142','46','Male','Master''s Degree','Senior Software Engineer','20','174938'), 
 ('00090','27','Female','Bachelor''s Degree','Junior Software Engineer','2','48000'), 
 ('00062','26','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00179','37','Female','Master''s','Software Manager','11','110000'), 
 ('00127','43','Male','PhD','Senior Project Engineer','13','185000'), 
 ('00014','31','Male','Bachelor''s','Data Analyst','9','195000'), 
 ('00039','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00108','44','Female','PhD','Senior Data Engineer','16','160000'), 
 ('00033','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00046','29','Male','Bachelor''s Degree','Front end Developer','3','80000'), 
 ('00148','45','Female','PhD','Senior UX Designer','16','160000'), 
 ('00168','28','Male','Bachelor''s Degree','Software Engineer','4','75000'), 
 ('00032','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00145','31','Female','Bachelor''s Degree','Senior Software Engineer','6','104378'), 
 ('00029','31','Female','PhD','Data Scientist','8','140000'), 
 ('00004','24','Male','Bachelor''s Degree','Back end Developer','1','55000'), 
 ('00100','26','Female','Bachelor''s Degree','Junior Web Developer','2','45000'), 
 ('00135','46','Male','PhD','Senior Researcher','18','150000'), 
 ('00056','27','Female','Master''s Degree','Full Stack Engineer','3','100000'), 
 ('00165','23','Female','Bachelor''s Degree','Software Engineer','1','50000'), 
 ('00048','25','Female','Bachelor''s Degree','Front end Developer','1','55000'), 
 ('00011','29','Female','Bachelor''s','Data Analyst','7','130000'), 
 ('00054','33','Female','Bachelor''s Degree','Full Stack Engineer','6','115000'), 
 ('00092','29','Male','Bachelor''s','Junior Web Designer','3','45000'), 
 ('00052','26','Male','Master''s Degree','Full Stack Engineer','4','102859'), 
 ('00042','26','Male','Master''s Degree','Front end Developer','3','73640'), 
 ('00160','30','Male','Bachelor''s Degree','Software Engineer','4','65000'), 
 ('00061','29','Male','Bachelor''s Degree','Full Stack Engineer','4','90000'), 
 ('00013','25','Male','Bachelor''s','Data Analyst','2','115000'), 
 ('00138','54','Other','High School','Senior Software Engineer','29','158966'), 
 ('00102','26','Female','Bachelor''s Degree','Junior Web Developer','2','45000'), 
 ('00134','46','Male','Master''s','Senior Project Manager','19','140000'), 
 ('00128','45','Male','PhD','Senior Project Engineer','16','185000'), 
 ('00036','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00172','45','Male','PhD','Software Engineer Manager','16','185000'), 
 ('00097','34','Male','Bachelor''s Degree','Junior Web Developer','3','50000'), 
 ('00118','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00001','29','Female','Master''s Degree','Back end Developer','3','90000'), 
 ('00072','26','Female','Bachelor''s Degree','Junior Software Developer','1','35000'), 
 ('00075','26','Female','Bachelor''s Degree','Junior Software Developer','2','35000'), 
 ('00091','25','Male','Bachelor''s Degree','Junior Software Engineer','1','55000'), 
 ('00076','28','Female','Bachelor''s Degree','Junior Software Developer','2','36000'), 
 ('00164','27','Female','Bachelor''s Degree','Software Engineer','3','70000'), 
 ('00111','47','Male','PhD','Senior Data Scientist','21','180000'), 
 ('00044','25','Female','Bachelor''s Degree','Front end Developer','1','55000'), 
 ('00053','28','Male','Master''s Degree','Full Stack Engineer','4','90452'), 
 ('00133','46','Male','Master''s','Senior Project Manager','21','135000'), 
 ('00096','24','Female','Bachelor''s Degree','Junior Web Developer','1','40000'), 
 ('00175','40','Male','Master''s Degree','Software Engineer Manager','16','150301'), 
 ('00121','47','Male','PhD','Senior Project Engineer','16','190000'), 
 ('00023','29','Female','Master''s','Data Scientist','6','180000'), 
 ('00022','30','Female','PhD','Data Scientist','7','170000'), 
 ('00002','38','Male','Bachelor''s Degree','Back end Developer','14','136449'), 
 ('00049','31','Female','Bachelor''s Degree','Front end Developer','6','110000'), 
 ('00188','24','Female','Bachelor''s Degree','Web Developer','1','40000'), 
 ('00079','28','Female','Bachelor''s Degree','Junior Software Developer','2','36000'), 
 ('00159','25','Female','Master''s Degree','Software Engineer','2','60000'), 
 ('00181','34','Female','Master''s','UX Designer','5','80000'), 
 ('00169','42','Male','Master''s Degree','Software Engineer Manager','13','170000'), 
 ('00120','43','Male','PhD','Senior Project Engineer','13','185000'), 
 ('00190','33','Male','Bachelor''s Degree','Web Developer','5','70000'), 
 ('00003','42','Male','Bachelor''s Degree','Back end Developer','16','137489'), 
 ('00182','28','Male','Master''s Degree','Web Developer','3','55000'), 
 ('00152','31','Male','Bachelor''s Degree','Software Developer','6','85000'), 
 ('00034','29','Male','Bachelor''s Degree','Front End Developer','4','80000'), 
 ('00105','44','Female','PhD','Senior Data Engineer','16','160000'), 
 ('00055','33','Female','Master''s Degree','Full Stack Engineer','9','136986'), 
 ('00084','27','Male','Bachelor''s Degree','Junior Software Engineer','1','55000'), 
 ('00045','23','Male','High School','Front end Developer','1','47898'), 
 ('00050','28','Female','Bachelor''s Degree','Front end Developer','2','65000'), 
 ('00161','27','Male','Bachelor''s Degree','Software Engineer','3','80000'), 
 ('00080','28','Female','Bachelor''s Degree','Junior Software Developer','2','37000'), 
 ('00167','24','Male','Bachelor''s Degree','Software Engineer','2','55000'), 
 ('00115','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00150','27','Male','Bachelor''s Degree','Software Developer','1','50000'), 
 ('00125','32','Male','Master''s Degree','Senior Project Engineer','11','128078'), 
 ('00010','23','Female','High School','Back end Developer','1','52807'), 
 ('00041','29','Male','Bachelor''s Degree','Front End Developer','3','70000'), 
 ('00129','41','Male','PhD','Senior Project Engineer','13','185000'), 
 ('00026','28','Female','PhD','Data Scientist','5','100000'), 
 ('00156','26','Male','Bachelor''s Degree','Software Developer','2','60000'), 
 ('00101','29','Male','Bachelor''s Degree','Junior Web Developer','2','45000'), 
 ('00155','24','Female','Bachelor''s Degree','Software Developer','2','55000'), 
 ('00170','54','Male','PhD','Software Engineer Manager','17','195000'), 
 ('00151','29','Female','Master''s Degree','Software Developer','5','70000'), 
 ('00119','42','Female','Master''s','Senior Graphic Designer','15','110000'), 
 ('00187','34','Male','Bachelor''s Degree','Web Developer','4','65000'), 
 ('00116','36','Male','PhD','Senior Data Scientist','12','170000'), 
 ('00043','28','Female','Bachelor''s Degree','Front end Developer','3','80000'), 
 ('00027','32','Female','PhD','Data Scientist','9','145000'), 
 ('00106','45','Male','PhD','Senior Data Engineer','16','150000'), 
 ('00176','52','Male','PhD','Software Engineer Manager','27','190596'), 
 ('00087','25','Male','Bachelor''s Degree','Junior Software Engineer','1','55000'), 
 ('00077','26','Female','Bachelor''s Degree','Junior Software Developer','2','35000'), 
 ('00024','31','Male','Master''s','Data Scientist','9','185000'), 
 ('00030','32','Female','PhD','Data Scientist','9','145000'), 
 ('00008','46','Female','Bachelor''s Degree','Back end Developer','19','150729'), 
 ('00067','27','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00064','27','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00071','27','Female','Bachelor''s Degree','Graphic Designer','2','50000'), 
 ('00183','32','Male','Master''s Degree','Web Developer','6','80000'), 
 ('00149','29','Male','Bachelor''s Degree','Software Developer','5','80000'), 
 ('00059','49','Male','Bachelor''s Degree','Full Stack Engineer','22','181132'), 
 ('00171','46','Female','PhD','Software Engineer Manager','14','180000'), 
 ('00126','45','Male','PhD','Senior Project Engineer','16','185000'), 
 ('00180','37','Male','Bachelor''s','Software Project Manager','9','95000'), 
 ('00110','33','Male','Master''s Degree','Senior Data Scientist','8','120000'), 
 ('00157','24','Female','Bachelor''s Degree','Software Developer','2','55000'), 
 ('00020','26','Male','Bachelor''s','Data Analyst','3','130000'), 
 ('00137','46','Male','Bachelor''s Degree','Senior Software Engineer','22','174324'), 
 ('00104','46','Male','PhD','Senior Data Analyst','17','160000'), 
 ('00082','26','Female','Bachelor''s Degree','Junior Software Engineer','1','45000'), 
 ('00016','35','Female','Master''s Degree','Data Analyst','9','120000'), 
 ('00083','27','Female','Bachelor''s Degree','Junior Software Engineer','2','48000'), 
 ('00005','26','Male','Bachelor''s Degree','Back end Developer','2','63789'), 
 ('00173','42','Male','Master''s Degree','Software Engineer Manager','13','170000'), 
 ('00185','33','Male','Bachelor''s Degree','Web Developer','5','70000');

2.หาข้อมูลที่ซ้ำกัน

SELECT Job_title, COUNT(*) AS duplicate_count
FROM ____
GROUP BY __
HAVING COUNT(*) > 1;
SELECT Job_title, COUNT(*) AS duplicate_count
FROM ____
GROUP BY __
HAVING COUNT(*) > 1;

3. select ที่มีข้อมูลเท่ากับ Senior UX Desinger

 

SELECT ___ FROM  ___ WHERE  ___ = 'Senior UX Designer';

4.delete ข้อมูลทีมี ค่าเท่ากับ Senior UX Designer

DELETE ___ FROM ___ WHERE ___ = ___ ;

Question 6 (alter)

เพิ่ม column ใน table ws6

  1. กำหนด id เป็น primary key
REATE TABLE 'ws6' ('id' INTEGER,

                             'name' TEXT,

                             'nickname' TEXT)

                              #INPUT CODE HERE;
INSERT INTO 'ws6' ('id','name','nickname') VALUES 
 ('66090500433','ธันยธรณ์ กองทองหลาง','เนท'), 
 ('66090500412','ปานวาด คะบูชา','มิ้ว'), 
 ('66090500434','ธีรภัทร์ ไพฑูรย์','ธี'), 
 ('66090500450','นภาเดช แก้วนอก','โอม'), 
 ('66090500403','ชานาธิป เขียวฉอ้อน','ฟลุ๊ค'), 
 ('66090500423','อธิฐาน มหามนต์','เดียร์'), 
 ('66090500436','นิชานันท์ บุญถนอม','กิ๊บ'), 
 ('66090500439','ยศพัทธ์ คุ้มวงศ์','ยูโร'), 
 ('66090500438','ปวรเกียรติ เมฆงาม','ปั๊บ'), 
 ('66090500422','นายสุขุมพัฒน์ รุจิธนัตโรจน์','ปาล์ม'), 
 ('66090500424','เอมี่ สุกัลญา ทริปป์','เอมี่'), 
 ('66090500408','นาย ณัฐวัฒน์ น้อยอุทัย','นัด'), 
 ('66090500432','ทินภัทร ตาคะนานันท์','ทิน'), 
 ('66090500421','สิทธาร คุณานิธ','ไหม'), 
 ('66090500402','ชนะโชติ บึงไกร','ป๊อบอาย'), 
 ('66090509437','นิติภูมิ พราหมณ์ศรีชาย','ภูมิ'), 
 ('66090500415','มงกุฎ วัฒนศิลปกิจ','ป๋วย'), 
 ('66090500451','พรพิมล พูลสวัสดิ์','อีฟ'), 
 ('66090500442','นายสุชาครีย์ พันชมภู','ต้า'), 
 ('66090500409','ต้นหยก บูรณวานิช','น้ำใส'), 
 ('66090500449','ณัฐวรา สาศรีเมือง','แอ้น'), 
 ('66090500420','สรวิชญ์ ห้องโสภา','นัม'), 
 ('66090500428','จิรัชญา สุวรรณชีวะศิริ','เฟิร์น'), 
 ('66090500444','สุพิชญากรณ์ ทองวร','เบสท์'), 
 ('66090500404','ณัฎฐินันท์ เกิดศรี','เซฟ'), 
 ('66090500419','วัฒนาสุข ลิมป์จรรยาวงศ์','แฟรงค์'), 
 ('66090500426','นายกิตติพศ วรรณภานุปทีป','เมเจอร์'), 
 ('66090500411','ธนวัฒน์ มะปะเท','แบงค์'), 
 ('66090500407','ณัฐภัทร สุวรรณศรีไพศาล','แบงค์'), 
 ('66090500416','นายวชิรวิทย์ เปรมไธสง','กาย'), 
 ('66090500401','นางสาวจันทร์ธิมา จันทร์หอม','พลอยดาว'), 
 ('66090500445','สุรสัณห์ โพธิจักร','ปุ้ย'), 
 ('66090500406','ณัฐพล เปรมกมล','ข้าวฟ่าง'), 
 ('66090500418','วัชรินทร์ ธาดาเจตสมบัติ','ก้อง'), 
 ('66090500425','กฤษฏิ์ ท้าวนาง','กิต'), 
 ('66090500440','รชตภัทร บุญมะหันต์','ไนซ์'), 
 ('66090500443','สุชานันท์ ทองชันลุก','มายด์'), 
 ('66090500427','นายเกียรติภูมิ ตั้งศรีทวีสุข','ภูมิ'), 
 ('66090500413','พงศธร ไวยวรณ์','ตี๋'), 
 ('66090502457','วิมลลักษณ์ สัตถาพร','หงส์'), 
 ('66090500429','นางสาว ญาณิศา คล่องแคล่ว','จูเลีย'), 
 ('66090500435','นฤพนธ์ ฉายสุวรรณคีรี','โอม'), 
 ('66090500447','อาชวิน ศุภนิทัศนาภร','ปลื้ม'), 
 ('66090500414','พิริยากร ศรีสุข','โอปอ');

2. เพิ่ม column email

3. ใส่ email ของตัวเองในชื่อ

ALTER TABLE ____ add ___  ___;
UPDATE ___  SET ___ = ___ WHERE ___ = ___;

4.โชว์ข้อมูลของตัวเอง

SELECT ___ FROM ___ WHERE ___ ;

Question 7 (Specialllllllll)

https://drive.google.com/file/d/1NUpDjESkAnyyLAopj_QjERirJiFLwBe0/view?usp=sharing

1.create table from data

2. กำหนด id เป็น primary key 

3. ใช้คำสั่ง select เพื่อแสดงคนที่มีเงินเดือนมากกว่า 100000 และน้อยกว่า 150000เรียงลำดับจากน้อยไปมาก

4. insert ข้อมูลของตัวเองเข้าไปในตาราง 

5.delete ข้อมูลคนที่เงินเดือนมากที่สุด

6. เพิ่มข้อมูล column บริษัทที่อยากทำในข้อมูลของตัวเอง และของเพื่อนอีก 2 คน

7.เปลี่ยนชื่อ table เป็น job_table_by_ชื่อตัวเอง

8.แสดงข้อมูลคนที่มีเพศขึ้นต้นด้วยตัว M  และ มีเงินเดือนมากกว่า 86000 และน้อยกว่า 130000 โดยเรียงลำดับจาก มากไปน้อย