AnsweredAssumed Answered

Query with both grouped and ungrouped fields

Question asked by texas0478 on Jun 9, 2017
Latest reply on Jun 10, 2017 by siplus

Hi,

 

I have a very simple question on a querying method, incl. only one table:

Say I've got this table as follows:

 

Name     City               Age     NumberOfDogs

-----------------------------------------------------

John       New York          40                    5

Rita           Boston            26                   3

John       New York          42                    2

Rita          Sydney            30                    1

John         Boston            41                    2

 

I would like to design a query which

- finds the oldest person among the ones sharing the same first name and living in the same
city AND

- displays how many dogs this person owns

 

Therefore the query should provide the following results:

Name     City               Age     NumberOfDogs

-----------------------------------------------------

Rita           Boston            26                   3

John       New York          42                    2

Rita          Sydney            30                    1

John          Boston           41                    2

 

I've been experimenting with self-join relationships and SQL subqueries but was unable to make it...

Either an SQL implementation or a TO model would be much appreciated.

 

Thanks

Gergő

 

PS. Greets from the sunny Budapest

Outcomes