Thursday, December 23, 2010

Grop by with multiple aggregate clauses

Multiple aggregate clauses in a group by..

select mstr_date
,sum((case when bs ='S' then -1 else 1 end )*quantity) as qty_sum
,sum((case when bs ='S' then -1 else 1 end)*orig_face) as orig_face_sum
,count(*)
from table_name
where column='xxxx'
group by mstr_date
order by mstr_date

I never tried this until now. Very interesting.

Thursday, December 2, 2010

Closing a Swing Application

Just calling toplevel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); is not good enough.
There could be other frames still alive, esp if you are using a third party library.
So your JVM is still running. Here is how you fix it..
Get all the frames that are currently running and dispose each of them

Frame[] frames = toplevel.getFrames();

for(int i=0;i
Frame frame = frames[i];
frame.dispose();
}
-Sonu