IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Re: Reply from Drew
How about something like

select o.ordernum, count(e.status)
from tbl_order o left outer join tbl_escalation e
on o.ordernum = e.ordernum and e.status = 'open'
group by o.ordernum
order by o.ordernum

You can then wrap count(e.status) in whatever formatting functions are available.
New You're ordering by the wrong thing
Yes, you can order by the count(*), but you're now subordering by the number of escalations and may want a different sort.

That is why I did all of the CASE garbage in my solution.

Cheers,
Ben
I have come to believe that idealism without discipline is a quick road to disaster, while discipline without idealism is pointless. -- Aaron Ward (my brother)
New Where do you see me ordering by count(*) ?
New You weren't, clarification
He wanted it sorted by whether any tickets were open. You weren't sorting by that, you were sorting by ordernum. Hence the title of my post.

I suggested that you could fix that to get something closer to what he wanted by sorting on count(*), but it doesn't support exactly the sort that I think he would eventually decide that he wants.

Cheers,
Ben
I have come to believe that idealism without discipline is a quick road to disaster, while discipline without idealism is pointless. -- Aaron Ward (my brother)
New Re: You weren't, clarification
Damn. You're right. I skipped over the ordering requirement.
     How to do without subqueries - (drewk) - (18)
         SELECT DISTINCT t1.* FROM t1, t2 ...? - (FuManChu)
         I don't understand your description - (ben_tilly) - (16)
             Reply from Drew - (Meerkat) - (15)
                 Re: Reply from Drew - (SpiceWare) - (6)
                     DECODE is Oracle-specific. -NT - (ben_tilly) - (5)
                         It is, but it is easy to clone - (tuberculosis)
                         Are you sure? I checked MySQL before posting - (SpiceWare) - (3)
                             They may have added it but it is not standard - (ben_tilly)
                             Seems to be specific to MaxDB - (JayMehaffey) - (1)
                                 That's rather confusing - (SpiceWare)
                 One solution - (JayMehaffey) - (1)
                     FWIW this was the best I saw for our needs - (drewk)
                 Untested, googling for supported syntax - (ben_tilly)
                 Re: Reply from Drew - (dws) - (4)
                     You're ordering by the wrong thing - (ben_tilly) - (3)
                         Where do you see me ordering by count(*) ? -NT - (dws) - (2)
                             You weren't, clarification - (ben_tilly) - (1)
                                 Re: You weren't, clarification - (dws)

I have a horse!
87 ms