I'm trying to count how many trips have been taken to California within two dates
I have the current XQuery that is as follows:
for $x in doc("triptracker.xml")/data/cities/city,
$y in doc("triptracker.xml")/data/trips/trip
let $date as xs:date := xs:date($y/date)
where $x/cityName = $y/cityName and $x/state = "CA" and
$date gt xs:date("2003-01-01") and $date lt xs:date("2006-12-31")
return <Result>Trips to California: {count($y)}</Result>
Which gives me the result set
<Result>Trips to California: 1</Result>
<Result>Trips to California: 1</Result>
<Result>Trips to California: 1</Result>
<Result>Trips to California: 1</Result>
<Result>Trips to California: 1</Result>
Instead of just giving me a count of 5
Here is the type of XML data being give for trip and city
<trips>
<trip>
<ssn>123-20-4567</ssn>
<cityName>Tucson</cityName>
<date>2001-08-11</date>
</trip>
</trips>
<cities>
<city>
<cityName>Houston</cityName>
<state>TX</state>
<location>
<latitude>29.76045</latitude>
<longitude>-95.369784</longitude>
</location>
</city>
</cities>
Any help would be greatly appreciated