티스토리 뷰

select top 1
from table1
inner join table2
on a = b
where a = b
and a ='JP' 
and a = 'Y'  

 

select
max(c)
, max(d)
from table1
inner join table2
on a = b
where a = b
and a ='JP'  
and a = 'Y' 

 

select
max(c)
, max(d)
from table1
inner join table2
on a = b
where a = b
and a ='JP'  
and a = 'Y' 
group by table1.a

 

"top 1""max()" 는 최종 검색 결과의 값중 1개만을 가져온다.

(조건절에 의해 여러 값이 성립된다해도 최상단 1개만을 가져온다.)

 

하지만 "max()" 와 "group by" 를 사용하면 조건절에 의해 성립된 모든 결과를 가져올 수 있다.

반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
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 28 29 30 31
글 보관함