Re: [SQL] slow count(CASE) query

2009-10-30 Thread Richard Huxton
Grant Masan wrote: > > select '000100' as length, sum(ship1) as ship1 ,sum(ship2) as > ship2,sum(ship3) as ship3,sum(ship4) as ship4,sum(ship5) as ship5 FROM > (select > count(CASE WHEN (type between 40 and 49) THEN 1 ELSE NULL END) as ship1, > count(CASE WHEN (type between 60 and 69) THEN 1 ELSE

Re: [SQL] slow count(CASE) query

2009-10-29 Thread Rob Sargent
Grant Masan wrote: > Hi all, > > I have this kind of query that I need to do, yes my query is giving > right answers now but it is long and slow. I am now asking you that if > you have another solution for my query to make that more smarter ! Hope > you can help me with this ! > > > select

Re: [SQL] slow count(CASE) query

2009-10-29 Thread Gerardo Herzig
Grant Masan wrote: > Hi all, > > I have this kind of query that I need to do, yes my query is giving right > answers now but it is long and slow. I am now asking you that if > you have another solution for my query to make that more smarter ! Hope you > can help me with this ! > > > select '0001

[SQL] slow count(CASE) query

2009-10-29 Thread Grant Masan
Hi all, I have this kind of query that I need to do, yes my query is giving right answers now but it is long and slow. I am now asking you that if you have another solution for my query to make that more smarter ! Hope you can help me with this ! select '000100' as length, sum(ship1) as ship1 ,s