I have a pair of selects that I am using with union_all and I'd like
to have better control of aliasing so I can use sum on the column in
the outer select that is made up of the count() and literal columns
from the unioned selects.
s1 = select([count(), id, name], cat_id == 6, [join(item_tbl,
Count needs to appear in the group by our be used in an aggregate
function, if I explictly add the literal 'count_1' as it is aliases to
the group by, the SQL executes, but then the count column is not sum'd
with the literal column and produces unwanted results.
What I need to do is sum the
For mySQL you could use unix_timestamp()
For Postgres you could use date_part('epoch',now())
I've always used DateTime personally and have only ever reflected
tables that used Integer timestamps. So I can't speak to the drawbacks
or potential impacts with any authority. There may also be a more
)
TT = s2.alias('TT')
u = union_all(s1, TT)
s = select([
u.c.id,
u.c.name,
func.sum(u.c.cnt).label('total')
]).group_by(TT.c.name, TT.c.id).order_by(TT.c.name)
print s
Wayne Witzel wrote:
Count needs to appear in the group by our be used in an aggregate
I assume I am over looking some simple thing, but I just can't seem to
find it. Thanks for the assist, I have palms open ready for face
planting.
Using a class and table with orm.mapper()
class Child(object):
pass
child_table = Table('child', meta.metadata,
Column('parent_id',
']), {})
Now all is well, sorry for the ML clutter. I am face palming in 3, 2,
1
On Apr 8, 4:49 pm, Wayne Witzel wwitz...@gmail.com wrote:
I assume I am over looking some simple thing, but I just can't seem to
find it. Thanks for the assist, I have palms open ready for face
planting.
Using
On Oct 15, 11:37 am, Heston James - Cold Beans
[EMAIL PROTECTED] wrote:
Quick question I hope guys.
If I have an object which contains a bunch of children and cascade is set on
the relationships. When I add the parent object to the session and commit
it, are the children saved as part of a
On Oct 13, 6:41 am, [EMAIL PROTECTED] wrote:
why i cannot give in_() a bindparam?
q.filter( x.in_( somelistorset )) works
q.filter( x.in_( bindparam('somename') )) fails
...
File sqlalchemy/sql/expression.py, line 1368, in _in_impl
for o in seq_or_selectable:
TypeError:
On Oct 13, 10:21 am, Michael Bayer [EMAIL PROTECTED] wrote:
On Oct 13, 2008, at 6:41 AM, [EMAIL PROTECTED] wrote:
why i cannot give in_() a bindparam?
q.filter( x.in_( somelistorset )) works
q.filter( x.in_( bindparam('somename') )) fails
...
File sqlalchemy/sql/expression.py,
I have the following code:
tags = [utag1, utag2]
tag_count = len(tags)
inner_q = select([shiptag_table.c.shipid])
inner_w = inner_q.where(
and_(shiptag_table.c.tagid == Tag.id,Tag.name.in_(tags))
On Oct 9, 10:20 am, Wayne Witzel [EMAIL PROTECTED] wrote:
I have the following code:
tags = [utag1, utag2]
tag_count = len(tags)
inner_q = select([shiptag_table.c.shipid])
inner_w = inner_q.where(
and_(shiptag_table.c.tagid == Tag.id
On Oct 9, 10:57 am, Michael Bayer [EMAIL PROTECTED] wrote:
the debug prints out the inner select statement non-nested in the
outer statement, so you get the full list of from clauses. the
func.count(shiptag_table.c.shipid) on the outer query sticks
shiptag_table in the outer FROM,
12 matches
Mail list logo