select
sum(s.cnt) as a1, s.INDATE as a2,m.SANAME as a3, s.code as a4, s.DANGA as a5,s.pumcd as a6
from gunguk AS s
left outer join jUNPYO as m
on m.CODE = s.CODE
and m.INDATE = s.INDATE
where s.pumcd = 'J0000442'
group by s.INDATE,m.SANAME, s.code, s.DANGA, s.pumcd
order by a2 desc,a4 desc
--------------------------------------------------------------
a1 a2 a3 a4 a5 a6
--------------------------------------------------------------
2664 79955 멍게수협 8 11100 J0000442
2663 79955 동아시아 7 10963 J0000442
1 79955 동아시아 7 11792 J0000442
1600 79950 창영 16 9700 J0000442
3200 79950 통영조합법 14 9600 J0000442
1599 79950 멍게 12 9488 J0000442
3100 79950 멍게 12 9500 J0000442
1 79950 멍게 12 9688 J0000442
3300 79950 김금진 9 9500 J0000442
=======================================
a1 합산값이 5000 까지만 불러오고 싶습니다.
제가원하는 결과는
--------------------------------------------------------------
a1 a2 a3 a4 a5 a6
--------------------------------------------------------------
2664 79955 멍게수협 8 11100 J0000442
2663 79955 동아시아 7 10963 J0000442 ------여기까지만
|