9-11) μ₯νκΈ μλ Ήμ΄μ‘μ΄ 500,000μμμ 2,000,000μ μ¬μ΄μ ν¬ν¨λμ§ μλ κ° νμμ νλ²μ μΆλ ₯νλΌ.
A)
mysql> select stu_no
-> from fee
-> group by stu_no
-> having not(sum(ifnull(jang_total, 0)) between 500000 and 2000000);
β
β
9-12) μ νλ λκ° 2002λ λΆν° 2006λ κΉμ§ μ νν νμμ νλ²κ³Ό μ νλ λλ₯Ό μΆλ ₯νλΌ.β
A)
mysql> select stu_no, fee_year
-> from fee
-> where fee_div='Y' and fee_enter is not null
-> and fee_year between 2012 and 2018;
β
β
9-13) μΆμλ λκ° 1998λ , 2000λ , 2002λ μ νμ΄λ νμμ νλ²κ³Ό μ΄λ¦, μΆμλ λλ₯Ό μΆλ ₯νλΌ.
A)
mysql> select stu_no, stu_name, substring(birthday,1,4)
-> from student
-> where substring(birthday,1,4) in (1998,2000,2002);
β
β
9-14) λμ΄κ° 19μΈλΆν° 23μΈ μ¬μ΄μΈ νμμ νλ²μ μΆλ ₯νλΌ.
A)
mysql> select stu_no
-> from student
-> where year(now())-substring(birthday,1,4)+1 between 19 and 23;
β
β
9-16) μμΈκ΄μμμ κ²½κΈ°λμ κ±°μ£Όνμ§ μλ νμμ λ²νΈ, μ΄λ¦, μ°νΈλ²νΈλ₯Ό μΆλ ₯νλΌ.
A)
mysql> select stu_no, stu_name, post_no
-> from student
-> where not(address like 'μμΈνΉλ³μ%' or address like 'κ²½κΈ°λ%');
β
β
9-17) μλ¬Έμ΄λ¦μ΄ λ¬Έμ 'Kim'μΌλ‘ μμνλ κ° νμμ νλ²λ΄ μ΄λ¦μ μΆλ ₯νλΌ.
A)
mysql> select stu_no, stu_name
-> from student
-> where stu_ename like 'Kim%';
β
β
9-18) μλ¬Έμ΄λ¦μ΄ 13λ¬Έμλ‘ κ΅¬μ±λ κ° νμμ μ΄λ¦κ³Ό νλ²μ μΆλ ₯νλΌ.
A)
mysql> select stu_no, stu_name
-> from student
-> where length(rtrim(stu_ename)) = 13;
β
β
9-19) μλ¬Έμ΄λ¦μ΄ 13λ¬Έμ μ΄μμΌλ‘ ꡬμ±λ κ° νμμ νλ²κ³Ό μ΄λ¦μ μΆλ ₯νλΌ.
A)
mysql> select stu_no, stu_name
-> from student
-> where length(rtrim(stu_ename)) > 13;
β
β
9-20) νμμ μλ¬Έμ΄λ¦μ΄ μμμ 4λ²μ§Έ λ¬Έμκ° 'g'μΈ νμμ κ° νλ²κ³Ό μ΄λ¦μ μΆλ ₯νλΌβ.
A)
mysql> select stu_no, stu_name
-> from student
-> where substring(stu_ename,4,1) = 'g';
β
β
9-21) λ€μ SELECT λͺ λ Ήλ¬Έμ μλ 쑰건μ μ λΉνλ€ or μ λΉνμ§λͺ»νλ€ ?
select * from student where stu_name is null;
β
A) quaryμμΌλ‘λ λ¬Έμ κ° μλ€. κ·Έλ¬λ stu_nameμλ null κ°μ΄ μ¬ μκ° μμ...
β
ββ
9-22) μ μ΄λ ν λ² μ΄μ μ₯νκΈμ μ§κΈ λ°μ νμμ νλ²κ³Ό μ΄λ¦μ μΆλ ₯νλΌ.
A)
mysql> select stu_no, stu_name
-> from student
-> where stu_no in
-> (select stu_no from fee where jang_total > 0);
β
mysql> select distinct s.stu_no, stu_name
-> from student s, fee f
-> where s.stu_no=f.stu_no and jang_total is not null;
β
β
9-23) 1,000,000 μ΄μμ μ₯νκΈμ μ μ΄λ ν λ² μ΄μ μ§κΈλ°μ νμμ νλ²κ³Ό μ΄λ¦μ μΆλ ₯νλΌ.
A)
mysql> select distinct s.stu_no, stu_name
-> from student s, fee f
-> where s.stu_no=f.stu_no and jang_total > 1000000;
β
β
9-24) μ μ΄λ ν λ² μ΄μ μ₯νκΈμ μ§κΈ λ°μκ³ λμ리μ κ°μ νμ§ μμ νμμ νλ²κ³Ό μ΄λ¦μ μΆλ ₯νλΌ.
A)
mysql> select distinct s.stu_no, stu_name
-> from student s, fee f
-> where s.stu_no=f.stu_no and jang_total is not null
-> and s.stu_no not in (select stu_no from circle);
β
β
9-26) λ¨νμ μ€ λμ΄κ° κ°μ₯ λ§μ νμμ νλ²κ³Ό μ΄λ¦, μΆμλ λλ₯Ό μΆλ ₯νλΌβ.
A)
mysql> select stu_no, stu_name, substring(birthday,1,4) 'μΆμλ λ'
-> from student
-> where birthday <= all
-> (select birthday from student where gender=1);
β
β
9-28) μ μ΄λ ν κ³Όλͺ© μ΄μ μκ°μ μ²μ ν νμμ μ΄λ¦κ³Ό νλ²μ μΆλ ₯νλΌ.
A)
mysql> select distinct stu_name, s.stu_no
-> from student s, attend a
-> where s.stu_no=a.stu_no;
β
β
9-29) νλ² 20191007λ²μ λ±λ‘λ λ, νκΈ°, λ±λ‘λ μ§μ μ΄λ¦μ μΆλ ₯νλΌ.
A)
mysql> select fee_year, fee_term, fee_date, s.stu_name
-> from fee f, student s
-> where s.stu_no=f.stu_no and f.stu_no='20191007';
β
β
9-30) μκ°μ μ²μ νμμΌλ 보κ΄μ±μ μ΄ μ‘΄μ¬νμ§ μλ νμμ νλ²κ³Ό μκ°λ λ, νκΈ°, μκ°κ³Όλͺ©μ μΆλ ₯νλΌ.
A)
mysql> select stu_no, att_year, att_term, sub_name
-> from attend a, subject s
-> where a.sub_code=s.sub_code
-> and stu_no not in (select stu_no from score);
β
β
9-31) λμ리 ν μ΄λΈμμ λμ리μ νμ₯μ νλ²κ³Ό μ΄λ¦, λμ리 λͺ μ μΆλ ₯νλΌ.
A)
mysql> select stu_no, stu_name, cir_name from circle where president=0;
β
β
9-32) λμ리μ μμλμ§ μμ νμμ νλ²κ³Ό μ΄λ¦μ μΆλ ₯νλΌβ
A)
mysql> select stu_no, stu_name
-> from student
-> where not exists
-> (select * from circle where stu_no = s.stu_no);
'Data Base > MySQL' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
MySQL 20λ²μ§Έμμ (0) | 2021.02.09 |
---|---|
MySQL 19λ²μ§Έμμ (0) | 2021.02.08 |
MySQL 17λ²μ§Έμμ (0) | 2021.02.08 |
MySQL 16λ²μ§Έμμ (0) | 2021.02.08 |
MySQL 15λ²μ§Έμμ (0) | 2021.02.08 |
λκΈ