[Babase] male dispersal query

Karl O. Pinc kop at meme.com
Thu May 20 16:12:44 EDT 2010


On 05/20/2010 03:01:00 PM, Niki Learn wrote:
> 
> On 05/14/2010 02:53:27 PM, Niki Learn wrote:
> > Main point:  I have encountered a similar problem (to the male
> > dispersal
> > query problem) when dealing with female sexual cycle data.  We
> > recently
> > wanted to know about the time period spent lactating and then
> cycling
> > after
> > each birth.  But each pid is linked to the cycle PRIOR to birth, 
> not
> > the one
> > after it.  I could not find a way to get babase to link to the 
> cycle
> > for the
> > next pid (which is tricky anyway since a few females have pids that
> > are out
> > of order or where one is skipped) and ended up having to run
> separate
> > queries, then line them up in Excel and calculate the cycling time
> > after
> > sorting by pid.
> 
> Does PREGS.Resume not do the trick?
> 
> Niki:  That's how I got one of the pieces.  I couldn't get babase to
> output
> them altogether though.


> Niki:  Maybe I need to know more SQL tricks?  There aren't very many
> listed
> in our "SQL for babase" page, I'll tell ya that.  I have gathered
> others off
> the internet from time to time as needed but I don't always know what
> can be
> done to look for.


The way to "put them together" is to use a self-join.
That's where the same table shows up twice in a single
query.  So you can take 2 queries and "merge" them
into one.

http://databases.about.com/od/sql/a/selfjoin.htm


Karl <kop at meme.com>
Free Software:  "You don't pay back, you pay forward."
                 -- Robert A. Heinlein




More information about the Babase mailing list