On Sunday, October 21, 2012 1:36:58 AM UTC-7, desbest wrote:

> For the first error, I would like to say that the posts.datenumber and 
> groups.datenumber column *does* exist. I probably should have made that 
> clear, 
> I've added the schema now. https://gist.github.com/3925058
> When I use the virtual row, it started working to do what I wanted it to 
> do. Thank you. It was a query to order groups based on recent activity, 
> excluding comment replies.
>  
> This leads me to my 2nd question.
>  
> How can I modify the first query that originally worked, so that inbetween 
> .order{max(posts__datenumber) and .order_append(:groups__datenumber), that 
> posts with a pond with more than zero 0, be excluded from the ordering of 
> the rows, or that the groups with a post above zero, gets lower presedence 
> in sorting?
>

You are joining to a subselect, which requires using an alias (Sequel 
creates uses a default alias if you don't specify one), you probably want 
"join(Post.where{floor > 0}.as(:posts), :group_id=>:id)".  The current code 
fails because in the query, posts.datenumber is not valid.  Also, you 
should probably remove the ".exclude()".

Note that you can call the sql method on any dataset to see the SQL it 
would generate, which would make it more obvious why SQLite didn't like 
your SQL.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/IPmxY5Y5_YoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to