카테고리 없음

221216

Berylly 2022. 12. 16. 20:01

T. 김동식 + 서치보완

 

 

MS949

Microsoft의 언어체제, 한글

 

 

JAVA

생성자 overloading, 생성자가 두개이상, 매개변수가 여러개 적재됨.

package constructorEx;
String name;
	float height;
	float weight;
	
	Person2() {}
	
	Person2(String name) {
		this.name = name;
	}
	
	Person2(String name, float height) {
		this.name = name;
		this.height = height;
	}
	
	Person2(float height, String name){
		this.name = name;
		this.height = height;
	}
	
	Person2(String name, float height, float weight){
		this.name = name;
		this.height = height;
		this.weight = weight;
	}
	
	public static void main(String[] args) {
		Person2 person2 = new Person2("박상희1 ");
		System.out.println(person2.name);
		
		Person2 person3 = new Person2("박상희2 ", 180.5f);
		System.out.print(person3.name);
		System.out.println(person3.height);
		
		Person2 person4 = new Person2(170.5f, "박상희3 ");
		System.out.print(person4.name);
		System.out.println(person4.height);
		
		Person2 person5 = new Person2("박상희4 ", 177.5f, 79);
		System.out.print(person5.name);
		System.out.print(person5.height);
		System.out.println(" "+person5.weight);
	}
}

 

 

returnItSelf(), 

자기 자신을 반환하는 메서드
반환값을 출력해보면 인스턴스의 메모리 주소가 담겨있다.

package constructorEx3;

class Person{
	
	String name;
	int age;
	
	public Person() {
		name = "이름없음";
		age = 1;
	}
	
	public Person(String name, int age) {
		this.name = name;
		this.age = age;
	}
	
	Person returnItSelf() {
		return this;
	}
	
}

class PersonTest{
	public static void main(String[] args) {

		Person person = new Person();
		
		System.out.println(person.name+", "+ person.age);
		
		Person itSelf = person.returnItSelf();
		
		System.out.println(itSelf);
		System.out.println(person);
	}
}

 

 

equals  true인지 false인지 출력해 확인할 수 있다.

String str = "yes";
System.out.println(str.equals("yes"));

 

 

ORACLE SQL

CREAT해 ALTER하거나 DROP할 수 있다.

완성된 DB는 SELECT로 진입해 INSERT하거나 UPDATE, DELETE할 수 있다.

DDL(Data Definition Language) 데이터 정의어

DML(Data Manipulation Language) 데이터 조작어

https://sanghee.tistory.com/52/#ddl_sanghee

 

221214

T. 김동식 + 서치보완 용어정리 정보저장 단위 byte (BKM GTP EZY) 1024byte = 1KB Kilo Byte 1024KB = 1MB Mega Byte 1024MB = 1GB Giga Byte 1024GB = 1TB Tera Byte 1024TB = 1PB Peta Byte 1024TB = 1EB Exa Byte 1024EB = 1ZB Zetta Byte 1024ZB = 1YB

sanghee.tistory.com

 

 

--검색
select * from customer where name = '김연아';
select * from customer where name like '김_아';
select * from customer where name like '김__';
select * from customer where name like '%김%';
--조회/중복제거
select publisher from book;
select DISTINCT publisher from book;

select count(publisher) from book;
select count( DISTINCT publisher) from book;
--alias 별칭
select count( DISTINCT publisher) as 출판자수 from book;
--집계함수 aggregate : sum, average, max, min, count
select * from orders;
select sum(saleprice) from orders;
select avg(saleprice) from orders;
select max(saleprice) from orders;
select min(saleprice) from orders;
select count(saleprice) from orders;
--between, 연산자, and/or
select * from book where price between 8000 and 20000;
select * from book where price >= 8000 and price <= 20000;
select count(*) from book where price >= 8000 and price <= 20000;
--in/not in 멤버쉽연산자, 포함하고있는가
select * from book where price in (10000, 20000, 30000);
select * from book where publisher not in('이상미디어', '나무수', '박상희');
--null/not null
select * from customer where phone is null;
select * from customer where phone is not null;
-- join 합하다 ',' 복합 정보를 얻어야될때, 조건필요, FOR문을 생각하자
select distinct customer.name as 주문한고객명 
	from orders, customer 
    where orders.custid = customer.custid;
-- group by: '기준'으로 집계, select에 '집계된 속성'만 나올수있다.
select custid, sum(saleprice) 
	from orders 
    group by custid;
   
-- sh 221216
-- 뭐랄까.. group by는 폴더 파일을 넣는것 같다.
-- 전체 주문내역(orders)에서 
-- 고객번호로 폴더를 만들어(custid)
-- 고객번호와 그 안의 값(sum(saleprice))을 보여준다
HAVING 검색조건: group by와 함께, where 뒤에 위치,  집계함수(sum, avg, max, min, count)가와야함.
select custid, count(*) 
	from orders 
    where saleprice >= 8000 --가격이 8000이상 도서를 구매한 고객에 대해
    GROUP BY custid  --고객별 주문도서의 총수량 = 고객id 기준으로 묶어 수량을 확인하고
    having count(*) > =2; --단 두권이상 구매한 고객만
    
 -- sh 221216
 주문내역에서(orders) 
 8000원이상 구매한 조건(where)으로 내역을 띄워
 고객(custid)별로 구매내역을 묶어놓는데
 이것을 세었을때(count(*)) 2권이상이라는 조건(having)으로
 고객(custid)과 그 구매내역 건수(count(*))를 띄우겠다.

 

 

where와 having의 차이

둘다 조건을 줄 수 있다는 것은 동일.

 

Group By(집계)를 기준으로 Where 은 앞, having 은 뒤에 위치.

즉, Where 는 집계전에 필터링을하고, having은 집계 후에 필터링을 한다.

 

= where는 기본적으로 모든 필드에 조건을 주지만, having은 그룹화된 그룹에만 가능하다.