CodePudding user response:
Select the mother's last name, mother's id number, gender, child birth dateThe from ZNXXB a
Where children time=1 and gender=female
And the exists (select top 1 1 from ZNXXB where mother id=a. id the mother and child=2 and child birth date between '2019-1-1' and '2019-12-31')
CodePudding user response:
Select the mother's last name, mother's id number, gender, child birth date
The from ZNXXB a
Where children time=1
And gender=N 'female'
And mother id in (Select id
The From (select mother id number, Max (child) as child time _count
The from ZNXXB
Where year (children's date of birth)=2019
Group by mother id) a
Where children _count=2)