1. 스프링 파일 import

 

spring5fs-master.zip
2.25MB

 

 

 

 

 

 

2. pom.xml 파일 버전  맞게 변경

 

 

 

3. 버전 변경 ( https://mvnrepository.com/ )

 

전체 복사
pom.xml 붙혀넣기

 

최종 pom.xml 파일

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>sp5-ch2</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <name>sp5-ch2</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
  </properties>



  <dependencies>
  <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>5.0.2.RELEASE</version>
</dependency>

  
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.7.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

자바스크립트

DOM

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="test"></div>
    <div class="test"></div>
    <div class="test"></div>
</body>
</html>

 

 

inner.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <button onclick="inntext()">innerText로 표시하기</button>
    <button onclick="innhtml()">innerHTML로 표시하기</button>
    <h1>현재시간</h1>
    <div id="current"></div>

    <script>
        const now = new Date();

        function inntext(){
            document.getElementById("current").innerText = now;
        }

        function innhtml(){
            document.getElementById("current").innerHTML = "<em>" + now + "</em>";

        }
    </script>

</body>
</html>

 

 

오라클

 

Update 예제 연습

 

update dept_temp2
 set dname = 'DATABASE',
    loc = 'NEW YORK'
where deptno = 40;

 

update emp_temp2
 set comm = 50
 where sal <=2500;

 

update dept_temp2
 set (dname, loc) = (select dname, loc
                        from dept
                        where deptno = 40)
  where deptno = 40

 

update dept_temp2
 set loc = 'SEOUL'
where deptno = (select deptno
                    from dept_temp2
                    where dname = 'OPERATIONS');

'프로젝트 기반 자바(JAVA) 응용 SW개발자 취업과정' 카테고리의 다른 글

2023-07-19 44일차  (0) 2023.07.19
2023-07-18 43일차  (0) 2023.07.18
2023-07-14 41일차  (0) 2023.07.14
2023-07-13 40일차  (0) 2023.07.13
2023-07-11 38일차  (1) 2023.07.11

자바스크립트

 

여행 준비물 점검 목록 만들기 ( 입력 값 밑에 저장 , 입력 값 옆에 x버튼 클릭 시 삭제 )

HTML

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>여행 준비물 점검 목록</title>
    <link rel="stylesheet" href="css/input.css">
    <link rel="stylesheet" href="css/list.css">
</head>
<body>
    <div id="wrapper">
        <h2>여행 준비물 점검 목록</h2>
        <form>
            <input type="text" id="item" autofocus="true">
            <button type="button" id="add" class="addBtn">추가</button>
        </form>
        <div id="itemList">
   
        </div>
    </div>    
   
    <script src="js/checklist-result.js"></script>
    </html>

 

CSS - 1

* {
  box-sizing:border-box;
}
#wrapper {
  width:600px;
  margin:0 auto;
}
h2 {
  text-align:center;
}
form {
  background-color:#007acc;
  padding:30px 40px;
  color:white;
  text-align:center;
}
input {
  border:none;
  width:440px;
  padding:10px;
  float:left;
  font-size:16px;
}
.addBtn {
  padding:10px;
  width:50px;
  border:none;
  background-color:#fff;
  box-shadow:1px 2px 4px #167dae;
  color:#555;
  text-align:center;
  font-size:14px;
  cursor:pointer;
  transition:0.3;
}
form::after {
  content:"";
  display:table;
  clear:both;
}

 

CSS - 2

form::after {
  content:"";
  display:table;
  clear:both;
}
ul{
  margin:0;
  padding:0;
  list-style: none;
}
ul li{
  cursor:pointer;
  position:relative;
  padding:12px 8px 12px 40px;
  background: #eee;
  font-size:18px;
  transition: 0.2s;
}
ul li:nth-child(odd) {
  background-color:#f9f9f9;
}
ul li:hover {
  background-color:#ddd;
}
.close {
  position:absolute;
  right:0;
  top:0;
  padding:12px 16px;
  border:none;
  background:rgba(255,255,255,0)
}
.close:hover {
  background-color:#007acc;
  color:white;
}

 

JS

// let nums = ['가방','칫솔','면도기'];
// nums.push('우산'); 값 추가
// nums.splice(2,1); 2번째 인덱스 1개 삭제

let itemList = [];
// 빈 배열 선언 사용자가 추가한 항목을 저장할 목록

const addBtn = document.querySelector("#add");
addBtn.addEventListener("click",addList);
// 클릭 이벤트가 발생하면 addList함수 호출

function addList(){
    // alert("클릭");

    let str = document.querySelector("#item");
    if (str.value != null && str.value != '' ){
        itemList.push(str.value);
        // str.value가 비어 있지 않은 경우에만 itemList 배열에 str.value를 추가

        str.value = '';// 입력 후 입력칸 초기화
        str.focus();
        //추가 후에는 입력칸(str)을 비우고 포커스를 다시 입력칸으로 이동
    }
    showList();

}

function showList(){
    let list = "<ul>";
    for(let i=0; i < itemList.length; i++){
        list += `<li>${itemList[i]}<span class='close' id='${i}'>X</span></li>`;
    //삭제 버튼에는 고유한 id를 부여하여 어떤 항목을 삭제해야 하는지 식별할 수 있도록 함
    }
    list += "</ul>";
    document.querySelector("#itemList").innerHTML = list;

    // 삭제
    let remove = document.querySelectorAll(".close");// 배열 형태
    // console.log(remove);
    for(let i = 0; i < remove.length; i++){
        remove[i].addEventListener("click", removeList);
    // 삭제 버튼에 클릭 이벤트 리스너를 추가하여 removeList 함수를 호출
    }

}
// 제거
//클릭된 삭제 버튼의 id를 가져와서 해당 id의 항목을 itemList 배열에서 제거
function removeList() {
    let id = this.getAttribute("id");
    console.log(id);
    itemList.splice(id, 1);
    showList();
    //showList 함수를 호출하여 목록을 업데이트
}

 

 

결과

등록

 

삭제

 

 

 

매개변수 값  함수로 지정하기

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // sum 함수: 배열의 합을 구하는 함수
        function sum(arr){
            let len = arr.length;
            let i = 0, sum = 0;

            // 배열의 각 요소를 순회하며 값을 더함
            for(; i < len; i++){
                sum += arr[i];
            }

            // 합을 반환
            return sum;
        }

        // 테스트할 배열
        const arr = [1, 2, 3, 4];
        
        // sum 함수 호출하여 결과 출력
        console.log(sum(arr));
        // 출력: 10 (1 + 2 + 3 + 4)

        // reduce 함수: 배열을 축소하는 함수
        function reduce(func, arr, memo){
            let len = arr.length,
                i = 0,
                accum = memo;

            // 배열의 각 요소를 순회하며 축소 함수를 적용하여 결과 값을 누적
            for(; i < len; i++){
                accum = func(accum, arr[i]);
            }  

            // 최종 누적 값을 반환
            return accum;
        }

        // 덧셈 함수
        let sum2 = function(x,y){
            return x + y;
        }

        // reduce 함수 호출하여 결과 출력
        console.log(reduce(sum2, arr, 0));
        // 출력: 10 (1 + 2 + 3 + 4)
    </script>
</body>
</html>

결과

 

 

오라클

 

Quiz 풀기

직책이 SALESMAN인 사람들의 최고 급여보다 높은 급여를 받는 사원들의 사원정보, 급여등급 출력

select e.empno, e.ename, e.sal, s.grade
 from emp e, salgrade s
 where sal between s.losal and s.hisal
  and e.sal > all (select sal
                    from emp
                    where job = 'SALESMAN'
                    )

 

 

 

테이블에 데이터 추가하기

 

DEPT 테이블을 복사해서 DEPT_TEMP 테이블 만들기

CREATE TABLE dept_temp
    AS SELECT * FROM dept

 

INSERT 데이터 추가 하기

insert into dept_temp (deptno, dname, loc)
                values(50, 'database', 'seoul');

 

 

INSERT 데이터 추가 할 때 NULL을 지정하여 입력하기

넣을 데이터가 없다면 ' ' 빈 문자열을 추가하는 것 보다 NULL로 지정하는게 좋음

insert into dept_temp (deptno, dname, loc)
                values(60, 'web', null);

 

테이블에 날짜 데이터 입력하기

날짜 데이터를 입력할 때는 문자열로 입력하기 보다는 TO_DATE함수를 사용하는 것이 좋다.

insert into emp_temp(empno, ename, job, mgr, hiredate, sal, comm, deptno)
                values(2222, '이순신', 'MANAGER', 9999, to_date('07/01/2001', 'DD/MM/YYYY'), 
                        4000, NUll, 20);

 

테이블에 현재 시간 날짜 데이터 입력하기 ( SYSDATE )

 

insert into emp_temp(empno, ename, job, mgr, hiredate, sal, comm, deptno)
                values(3333, '심청이', 'MANAGER', 9999, sysdate, 
                        4000, NUll, 20);

 

 

 

 

 MyBatis 설정 

 

1. 만들어 둔 zip 파일 압축 해제

myBatis0714_1.zip
0.01MB

 

 

 

2. 이클립스 패키지 경로에 폴더 넣기

 

3. Import 시키기

 

 

 

 

 

4. jar 파일 Build Path

 

jar.zip
10.75MB

 

 

 

4. 파일 위치 확인

 

'프로젝트 기반 자바(JAVA) 응용 SW개발자 취업과정' 카테고리의 다른 글

2023-07-18 43일차  (0) 2023.07.18
2023-07-17 42일차  (0) 2023.07.17
2023-07-13 40일차  (0) 2023.07.13
2023-07-11 38일차  (1) 2023.07.11
2023-07-10 37일차  (0) 2023.07.10

 

프로젝트 선택 후 우클릭 밑 줄친 경로 클릭 ( 아무런 반응 없음 ) 

 

밑 줄친 경로에서 web.xml이 생성됨

 

 

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0">
  <display-name>oracle0703</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  
  <servlet>
  <servlet-name>listServ</servlet-name>
  <servlet-class>oracle0703.ListServ</servlet-class>
  </servlet>
  
  <servlet-mapping>
  <servlet-name>listServ</servlet-name>
  <url-pattern>/listServ</url-pattern>
  </servlet-mapping>
</web-app>

 

web.xml 코드 확인

 

 

 

 

package oracle0703;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import board.oracle.BoardDao;
import board.oracle.BoardDto;

/**
 * Servlet implementation class ListServ
 */
//@WebServlet("/listServ")
public class ListServ extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ListServ() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		BoardDao dao = new BoardDao();
		ArrayList<BoardDto> list = dao.selectList();

		request.setAttribute("list", list);
		RequestDispatcher dispatcher
		 = request.getRequestDispatcher("boardView.jsp");
		dispatcher.forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}

 

Servlet 파일에서 주석 친  @WebServlet("/listServ") 부분이 최신 방식 위에 web.xml 예전 방식

 

나중에 회사 들어가서 xml로 코드를 짜놨을지 모르니 확인 하는게 중요 

 

현재는 사용 x  

 

자바스크립트

 

객체생성, 배열 생성, 출력 

HTML

<!DOCTYPE html>
<html lang="ko">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>도서 관리 프로그램 - 객체 만들기</title>
	<link rel="stylesheet" href="css/book.css">
</head>
<body>
	

	<script src="js/book-result.js"></script>
</body>
</html>

 

CSS

body { background:url('../images/bg.png') repeat-x top left;	}
h1 { margin-top:180px; }
p { width:400px; margin-bottom:10px; padding:10px; border:1px solid #ccc;
     color: #ccc; background-color: black;}

 

JS

// 생성자
function Book(title, author, volume, price){
    this.title = title,
    this.author = author,
    this.volume = volume,
    this.price = price;
}
// 객체 생성
let html = new Book('웹표준의 정석', 'ko', '608', '28,000');
let youtube = new Book('유튜브 영상 만들기', 'Kim', '368', '16,000');
let python = new Book('점프 투 파이썬', 'Park', '352', '18,800');

// 배열 생성, 출력
let booklist = [html, youtube, python];
for(let i = 0; i < booklist.length; i++){
    document.write(`<p>${booklist[i].title}</p>`);
}

 

결과

 

 

 

객체 선언 / 프로퍼티와 메서드 정의 / 호출

HTML

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>사용자 정의 객체</title>
    <link rel="stylesheet" href="css/obj.css">
</head>
<body>
    <div id="display"></div>
    <script src="js/object-result.js"></script>
   
</body>
</html>

CSS

        #display {
            width:500px;
            margin:20px auto;
            padding:10px;
            border:1px solid #ccc;
            text-align:center;
            font-size:20px;
            line-height:30px;
        }


JS

var toyRobot = { // toyRobot 객체를 선언한 후 프로퍼티와 메서드 정의
    productID : "123-12",
    name : "Robot",
    price : "25,000",
    madein : "Korea",
    quantity : 10,
    showStock : function(){ // showStock( ) 메서드 정의
        document.querySelector('#display').innerHTML
        = this.name + "제품은" + this.quantity + "개 남아있습니다.";
    }
}
toyRobot.showStock();

//,
// showPrice : function(){
//     alert(this.name + "제품의 가격은" + this.price + "입니다.");
// }

 

결과

Quiz 1 _ 변수 선언 후 객체 생성 / 출력

HTML + CSS

<!doctype html>
<html lang="ko">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>memeber 객체</title>
    <style>
        body {font-size:1.2em; line-height: 2em;}
    </style>
</head>
<body>
    <script src="js/quiz1-result.js"></script>
</body>
</html>

 

JS

const id = 123;
const name = '홍길동';
const age = 25;
const address = '구로구'

const member1 = {id, name, age, address}



document.write("<h2>" + member1.name + "</h2>");
document.write("<ul><li>id : " + member1.id + "</li>");
document.write("<li>나이 : " + member1.age + "</li>");
document.write("<li>주소 : " + member1.address + "</li></ul>");  

 

결과

 

Quiz 2 _ 명언 배열 생성 후 2초마다 새로운 명언 출력

HTML + CSS

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>연습문제</title>
    <style>
            body {
                font-family:'Nanum Pen Script', "맑은 고딕";
                padding-top:20px;
                font-size:2.5em;
                text-align: center;
            }
        </style>
</head>
<body>
    <div id="quiz">
    <script src="js/quiz-2.js"></script>
</div>
</body>
</html>

JS

var quotes = [];
quotes[0] = "당신은 지금도 최고고, 이전에도 최고였으며 앞으로도 최고일 것입니다.";
quotes[1] = "성공하는 사람은 실패하는데 익숙한 사람이다.";
quotes[2] = "후회를 최대한 이용하라. 깊이 후회한다는 것은 새로운 삶은 산다는 것이다.";
quotes[3] = "가짜 친구는 소문을 믿고 진짜 친구는 나를 믿는다.";
quotes[4] = "성공이라는 못을 박으려면 끈질김이라는 망치가 필요하다.";
quotes[5] = "인생이란 결코 공평하지 않다. 이 사실에 익숙해져라.";
quotes[6] = "'언젠가'라는 날은 영원히 오지 않는다.";
quotes[7] = "문제점을 찾지 말고 해결책을 찾으라.";
quotes[8] = "착한 일은 작다 해서 아니하지 말고, 악한 일은 작다 해도 하지 말라.";
quotes[9] = "자존심은 어리석은 자의 소유물이다";

// var index = 0;
//let index = Math.floor(Math.random()*10);
//document.write("<p>&quot;" + quotes[index] + "&quot;</p>")

// 2초마다 출력
// document.querySelector('#quiz').innerHTML ( div id )
setInterval(() => {
    const index = Math.floor(Math.random()*10);
    document.querySelector('#quiz').innerHTML=("<p>&quot;" + quotes[index] + "&quot;</p>");
         }, 2000);

결과

 

 

오라클

 

서브쿼리

SQL문을 실행하는 데 필요한 데이터를 추가로 조회하기 위해 SQL문 내부에서 사용하는 SELECT문 의미

조회 대상의 오른쪽에 놓이며 괄호 ( ) 로 묶어서 사용

 

예) 
사원이름이 ALLEN인 사원의 추가 수당보다 많은 추가 수당을 받는 사원 정보를 출력

select *
 from emp
where comm > (select comm
               from emp
               where ename = 'ALLEN'
                        )

 

 

 

실행 결과가 하나인 단일행 서브쿼리

서브쿼리에서 출력되는결과가 하나이므로 메인쿼리와 서브쿼리 결과는 단일행 연산자를 사용해서 비교

 

서브쿼리의 결과 값이 날짜형인 경우 ( 빨리 입사한 사원 목록 조회 )

select *
 from emp
where hiredate < (select hiredate
               from emp
               where ename = 'SCOTT'
                        )

SCOTT보다 빨리 입사한 직원 목록

 

 

테이블 조인 후 SELECT문에 서브쿼리 적용 ( 서브쿼리 안에서 함수 사용 ) 

select e.empno, e.ename, e.job, e.sal, d.deptno, d.dname
 from emp e, dept d
where e.deptno = d.deptno
 and e.deptno = 20
 and e.sal > (select avg(sal) from emp)

 

 

실행 결과가 여러 개인 다중행 서브쿼리

단일행 서브쿼리와 달리 서브쿼리 결과가 여러 개이므로 단일행 연산자는 사용할 수 없고 다중행 연산자를 사용해야

메인쿼리와 비교할 수 있다.

 

IN연산자

메인쿼리의 데이터가 서브쿼리의 결과 중 하나라도 일치한 데이터가 있다면 true

부서 번호가 20이거나 30인 사원의 정보만 출력 

select *
 from emp
where deptno in (20, 30);

 

각 부서별 최고 급여와 동일한 급여를 받는 사원 정보 출력

select *
 from emp
where sal in (select max(sal)
                from emp
               group by deptno   )

 

서브쿼리의 SELECT문 결과 값이 밑에 쿼리문 처럼 2850, 3000, 5000이 출력되는데 IN연산자를 사용해 메인쿼리에서는

세 값 중 일치하는 값을 가진 행만 출력한다.

select max(sal)
 from emp
group by deptno

 

EXISTS 연산자

서브쿼리에 결과 값이 하나 이상 존재하면 조건식이 모두 true ( 전부 출력 ), 존재하지 않으면 모두 false 

 

서브쿼리 결과 값이 존재하는 경우

모두 출력 

select *
 from emp
where EXISTS ( select dname
                from dept
                where deptno = 10);

서브쿼리 결과 값이 존재하지 않는 이유

아무것도 출력 안됨 50은 없기 때문에 

select *
 from emp
where EXISTS ( select dname
                from dept
                where deptno = 50);

 

 

 

 

비교할 열이 여러 개인 다중열 서브쿼리

서브쿼리의 SELECT절에 비교할 데이터를 여러 개 지정하는 방식

select *
 from emp
where (deptno, sal) in ( select deptno, max(sal)
                			from emp
                		group by deptno);

 

 

오라클 퀴즈 

Quiz-1 

전체 사원 중 ALLEN과 같은 직책인 사원들의 사원 정보, 부서 정보를 출력

select e.job, e.empno, e.ename, e.sal, d.deptno, d.dname
    from emp e, dept d
    where e.deptno = d.deptno
     and job = (select job from emp where ename = 'ALLEN')

 

Quiz-2

전체 사원의 평균 급여보다 높은 급여를 받는 사원들의 사원 정보, 부서 정보, 급여 등급 정보 출력 

( 단 출력할 때 급여가 많은 순으로 정렬하되 급여가 같을 경우에는 사원 번호를 기준으로 오름차순 정렬 ) 

select e.empno, e.ename, d.dname, e.hiredate, d.loc, e.sal, s.grade
    from emp e, dept d, salgrade s
    where e.deptno = d.deptno
     and e.sal between s.losal and s.hisal
     and sal > (select avg(sal) 
                from emp )
                order by e.sal desc, e.empno;

 

Quiz-3

10번 부서에 근무하는 사원 중 30번 부서에는 존재하지 않는 직책을 가진 사원들의 사원 정보, 부서 정보 출력

select e.empno, e.ename, e.job, d.deptno, d.dname, d.loc
 from emp e, dept d
 where e.deptno = d.deptno
  and e.deptno = 10
  and job not in (select distinct job from emp where deptno = 30);

 

결과가 해당처럼 나와야 됨

 

 

 

서브 쿼리 뺀 결과 값

select e.empno, e.ename, e.job, d.deptno, d.dname, d.loc
 from emp e, dept d
 where e.deptno = d.deptno
  and e.deptno = 10

 

 

 

해당 문제 풀때는 서브쿼리 문 안에 내용을 확인 후 제외 시킬 인원 목록 확인 

select distinct job from emp where deptno = 30

 

 

'프로젝트 기반 자바(JAVA) 응용 SW개발자 취업과정' 카테고리의 다른 글

2023-07-17 42일차  (0) 2023.07.17
2023-07-14 41일차  (0) 2023.07.14
2023-07-11 38일차  (1) 2023.07.11
2023-07-10 37일차  (0) 2023.07.10
2023-07-07 36일차  (0) 2023.07.07

+ Recent posts