Say I have a table: 

```
CREATE TABLE births 
(
    childid INT,
    momid INT,
    eclampsia VARCHAR(1),
    preeclampsia VARCHAR(1),
    hypertension VARCHAR(1)
);

```

Insert records:

```
INSERT INTO BIRTHS (CHILDID, MOMID, ECLAMPSIA)
VALUES (654321, 123456, 'Y'),
       (654321, 123456, 'Y'),

INSERT INTO BIRTHS (CHILDID, MOMID, HYPERTENSION)
VALUES (987652, 465468, 'Y'),
       (987987, 465468, 'Y')

INSERT INTO BIRTHS (CHILDID, MOMID)
VALUES (687765, 465468)

INSERT INTO BIRTHS (CHILDID, MOMID, PREECLAMPSIA)
VALUES (649870, 846587, 'Y')

INSERT INTO BIRTHS (CHILDID, MOMID)
VALUES (787463, 846587);

```

I want to return records for all mothers who have had more than one child and have had one of these three diagnoses in more than one pregnancy. 

My expected results are: 

```
 child    momid     eclampsia    preeclampsia    hypertension
 -------------------------------------------------------------
 654321   123456       Y
 431265   123456                     Y
 987652   465468                                     Y
 987987   465468                                     Y

```

How would I do write this? 

I have a sloppy query that does not quite do what I want. It works to some degree, but still gives me records where the momid has had a diagnosis only for one pregnancy. 

```
select distinct 
    a.*, b.eclampsia, b.preeclampsia, b.hypertension 
from 
    births a
join 
    births b on a.momid = b.momid
where 
    a.childid != b.childid 
    and a.eclampsia = 'y' 
    and (b.eclampsia = 'y' or b.preeclampsia = 'y' or b.hypertension = 'y') 
     or a.preeclampsia = 'y' 
    and (b.preeclampsia = 'y' or b.eclampsia = 'Y' or b.hypertension = 'y') 
     or a.hypertension = 'y' 
    and (b.hypertension = 'y' or b.eclampsia = 'y' or b.preeclampsia = 'y')
order by  
    mapersonid 

```