0

I have a table with columns(id, name, title, time), I want to get a query that gives each row a virtual number by counting row with time condition!
My sql Select is this:

SELECT 
    aTbl.name, 
    aTbl.title, 
    (
        SELECT COUNT(*) 
        FROM tbl AS tmpTbl 
        WHERE tmpTbl.time > aTbl.time
    ) AS serviceNumber
FROM tbl AS aTbl 
ORDER BY serviceNumber  

How can I get query like this with propel query class ?
If this can't happen, what alternative way would you suggest for doing it?

thanks ;-)

cyfur01
  • 3,262
  • 1
  • 34
  • 38
X.Strange
  • 175
  • 1
  • 16
  • 1
    @Drew I seem to find that the ORM tools _do_ make basic queries easy, but for more complex stuff (like this question), they usually have a "raw" function. – Tim Biegeleisen Jun 25 '16 at 07:25
  • 1
    @TimBiegeleisen well the "raw" functionality is the first I look for with any orm to break people out of the box or handcuffs. Which defeats the purpose of even using it certainly. But if there is no raw functionality I certainly would never use that orm. We spend too much time with orms getting them to work on this site. Hopefully you have success with this SO search of propel with the keyword raw: http://stackoverflow.com/search?tab=votes&q=%5bpropel%5d%20raw – Drew Jun 25 '16 at 18:12
  • I know I can get the PDO connection from Propel and use it for any query that I want, But I'm trying to find is there any Propel way to do this like other things we can do with query class? – X.Strange Jun 26 '16 at 01:48

0 Answers0