These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: HQL: How to order by an anonymous nested select
PostPosted: Tue Apr 14, 2009 10:03 am 
Newbie

Joined: Fri Apr 10, 2009 4:30 am
Posts: 1
Code:
SELECT
DISTINCT u.email,
su.metaInfo,
(SELECT count(*) as viewCount
        FROM StatisticEvent se, Subscription s
        WHERE se.eventType = 'display' and
        se.subscription.id = s.id and
        s.campaign.id = 1 and
        s.user.id=u.id) ,
(SELECT count(*) as clickCount
        FROM StatisticEvent se, Subscription s
        WHERE se.eventType = 'click' and
        se.subscription.id = s.id and
        s.campaign.id = 1 and
        s.user.id=u.id) as clicks
FROM User u, Subscription su
WHERE u.id = su.user.id AND su.campaign.id =  1
ORDER BY  u.email


I can easily order by the email field, but how do I order by one of the anonymous nested queries? As you can see I have tried some aliasing but never had any success.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.