혹시 오라클의 count over(partition by...) 이거 mysql에서도 쓸수 있는 방법 없을까 ㅠㅜ
over가 없는거 같던데... count over 써서 그룹바이 할필요 없는데 오라클에선.. mysql에선 가능한지 모르겠네
댓글 10
select col, count(col) from table group by col
monoless(lazzarus)2011-08-30 09:11
이거 아닌가?
monoless(lazzarus)2011-08-30 09:15
음 오라클에선 select col1,count(col2) over(partition by col2) 하면 col1값은 그대로 나오고.. col2는 col2의 그룹에 따라 카운트 수가 나오거던.. 그룹바이로 압축을 안해도.. 쓸수가 있는데.. mysql은 이게 지원이 안되니.. 횽이 적어준 쿼리는 컬럼이 하나일 경우고 그거의 카운트만 구할때는 가능한데... 컬럼이 10개일 경우에 한개의 컬럼만 압축하는게 불가능 하자나... count over는 그게 가능한데..
쿄스케(keoerd)2011-08-30 09:19
select col as idx, count(col) as quantity, (select col2 from table where col=idx limit 1) as referer from table group by col
monoless(lazzarus)2011-08-30 09:24
subquery 쓰자;
monoless(lazzarus)2011-08-30 09:24
간단하게.. select col1,col2,col3,(select count(*) from test) col4 from test 이렇게 하면 col1 2 3과 총 카운트수가 나오겠지... 이게 mysql 문법이라면 oracle 에선 select col1,col2,col3,count(*) over() col4 from test 이런식으로 스칼라 서브쿼리를 쓸 필요가 없어져.. 이건 간단한거고 ㅠㅜ 내가 하려는건 더 복잡해서 count over를 써야하는 상황이라.. 안그러면 스칼러
쿄스케(keoerd)2011-08-30 09:26
mysql 에선 서브쿼리를 쓸수 밖에 없나 ㅠㅜ...
쿄스케(keoerd)2011-08-30 09:27
select a.*, b.* from (select col as idx, count(col) as quantity from table group by col) as a inner join table as b on a.idx=b.col
select col, count(col) from table group by col
이거 아닌가?
음 오라클에선 select col1,count(col2) over(partition by col2) 하면 col1값은 그대로 나오고.. col2는 col2의 그룹에 따라 카운트 수가 나오거던.. 그룹바이로 압축을 안해도.. 쓸수가 있는데.. mysql은 이게 지원이 안되니.. 횽이 적어준 쿼리는 컬럼이 하나일 경우고 그거의 카운트만 구할때는 가능한데... 컬럼이 10개일 경우에 한개의 컬럼만 압축하는게 불가능 하자나... count over는 그게 가능한데..
select col as idx, count(col) as quantity, (select col2 from table where col=idx limit 1) as referer from table group by col
subquery 쓰자;
간단하게.. select col1,col2,col3,(select count(*) from test) col4 from test 이렇게 하면 col1 2 3과 총 카운트수가 나오겠지... 이게 mysql 문법이라면 oracle 에선 select col1,col2,col3,count(*) over() col4 from test 이런식으로 스칼라 서브쿼리를 쓸 필요가 없어져.. 이건 간단한거고 ㅠㅜ 내가 하려는건 더 복잡해서 count over를 써야하는 상황이라.. 안그러면 스칼러
mysql 에선 서브쿼리를 쓸수 밖에 없나 ㅠㅜ...
select a.*, b.* from (select col as idx, count(col) as quantity from table group by col) as a inner join table as b on a.idx=b.col
아이고 출근길 아이폰으로 뭐하는 짓이야 ㅋㅋㅋㅋㅋ
monoless 횽 고마워 참고할께