Here's my delemna:<br>
<br>
I need to grab no more than three records from a table per company in a table that meets a certain criteria.<br>
<br>
Here's a table to use for this question. <br>
<br>
((I can't figure out how to get this to show in a formatted output, sorry))<br>
<br>
CONTACT<br>
NAME TITLE COMPANY<br>
-------------------------- ----------------- ---------------------<br>
JOHN SMITH PRESIDENT DETROIT MOTORS, INC.<br>
DAVID BUEHLER VICE-PRESIDENT DETROIT MOTORS, INC.<br>
BOB WHEELER CHAIRMAN DETROIT MOTORS, INC.<br>
STAN RECORD VICE-PRESIDENT DETROIT MOTORS, INC.<br>
CATHY PAGE CHAIRMAN BOOK INN<br>
DANIEL TARIN PRESIDENT BOOK INN<br>
ERIC LEAVENWORTH VICE PRESIDENT BOOK INN<br>
RICHARD BURNHAM CIO BOOK INN<br>
…<br>
DANIEL PELTON CEO BOOK INN<br>
<br>
I need to write a query from the CONTACT table that will show no more than 3 contacts per company that meet the chief contact criteria.<br>
<br>
Here's what I've got but, it's not working.<br>
<br>
select C.Name, C.Title, C.Company from Contact C<br>
where Exists (Select * from contact <br>
where ( title like "%pres%" or<br>
title like "%CIO%" or<br>
title like "%CEO" or<br>
title like "%CHAIR%"
<br>
Group by Company)<br>
<br>
<br>
Any ideas?<br>
<br>
MapMan<br>
<br>
I need to grab no more than three records from a table per company in a table that meets a certain criteria.<br>
<br>
Here's a table to use for this question. <br>
<br>
((I can't figure out how to get this to show in a formatted output, sorry))<br>
<br>
CONTACT<br>
NAME TITLE COMPANY<br>
-------------------------- ----------------- ---------------------<br>
JOHN SMITH PRESIDENT DETROIT MOTORS, INC.<br>
DAVID BUEHLER VICE-PRESIDENT DETROIT MOTORS, INC.<br>
BOB WHEELER CHAIRMAN DETROIT MOTORS, INC.<br>
STAN RECORD VICE-PRESIDENT DETROIT MOTORS, INC.<br>
CATHY PAGE CHAIRMAN BOOK INN<br>
DANIEL TARIN PRESIDENT BOOK INN<br>
ERIC LEAVENWORTH VICE PRESIDENT BOOK INN<br>
RICHARD BURNHAM CIO BOOK INN<br>
…<br>
DANIEL PELTON CEO BOOK INN<br>
<br>
I need to write a query from the CONTACT table that will show no more than 3 contacts per company that meet the chief contact criteria.<br>
<br>
Here's what I've got but, it's not working.<br>
<br>
select C.Name, C.Title, C.Company from Contact C<br>
where Exists (Select * from contact <br>
where ( title like "%pres%" or<br>
title like "%CIO%" or<br>
title like "%CEO" or<br>
title like "%CHAIR%"
Group by Company)<br>
<br>
<br>
Any ideas?<br>
<br>
MapMan<br>