[xquery-talk] where clause

daniela florescu dflorescu at me.com
Thu Mar 28 08:23:02 PST 2013


Michael,

in addition to the queries I already gave you with count and groupby, here is another one in 
pure XQuery  1.0  that cannot be reduced

declare function foo($x) 
{
    if ($x/@a) then $x else <b/>
};


for $x in Blah1
for $y in Blah2
let $z := foo($y)
where $z is $z
return $x


(variable $z cannot be unfolded because of the generation of new nodes, and then the where cannot be move up because
of the let)


Sorry, I felt like being twisted minded this morning :-)

XQuery is wicked :-)

Best
Dana


On Mar 27, 2013, at 7:10 PM, Michael Sokolov wrote:

> (forwarding Daniela's message)
> 
> Michael,
> 
> I think the ones with grouby and a where after the groupby are impossible to rewrite
> in general (remember this from my optimizing SQL days). In this case the WHERE is the good old
> HAVING clause of SQL.
> 
> Something along the lines of
> 
> for $x in blah
> for $y in blah
> group by $z:= $x/a, $t:= $y/b
> where $z+$t >25
> return $z
> 
> I am putting an informal syntax, obviously.
> 
> Another case is when the COUNT clause exists. You cannot move the where up and down in the tuple stream in
> such a case.
> 
> for $x in Blah1
> for $y in Blah2
> count $i
> where $x/a eq $y/b
> return something using $i
> 
> 
> HTH
> Dana
> 
> 
> On Mar 27, 2013, at 5:31 AM, Michael Sokolov wrote:
> 
>> I'm trying to come up with examples in which "where" clauses cannot be rewritten as XPath predicates.  So far, the ones I have all involve an "at" counter.  Are there others?
>> 
>> --
>> Michael Sokolov
>> Senior Architect
>> Safari Books Online
>> 
>> _______________________________________________
>> talk at x-query.com
>> http://x-query.com/mailman/listinfo/talk
> 
> 
> 
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk




More information about the talk mailing list