Skip to Main Content

Endeca Experience Management

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Find players who are above-average age of their teammates query

User_JUW53Nov 30 2020

Hi all! I am just beginning to learn the ins and out of database querying and have been stuck on this particular query for quite a while.
I am trying to list the names of players who are above average age of their teammates.
A few of my attempts have gotten close, but are not returning the right results.
Ideally I am trying to find the average age grouped by team, and test each player to see if they are older than that value.
My relational schema are as follows:
player(player_name, age, field_position)
plays_for(player_name, team_name)
This is my proposed query that runs without error, but returns me players above the total average age, not the average age of their respective team.
Any and all help or insight would be greatly appreciated.
A friend suggested perhaps making 2 copies of players and plays_for, but I'm unfamiliar with that technique.

SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

select A.player_name 
  from plays_for A
  join player B 
    on A.player_name = B.player_name
 where B.age > (select avg(age) from player
group by A.team_name

Comments

Arnoschots-Oracle Apr 22 2020 — edited on Apr 22 2020

Hi,

The "sudo al-config -s" doesn't work on my Autonomous Linux instance.

Command output:

[opc@opsserver ~]$ sudo al-config -s

/sbin/al-config: illegal option -- s

Configure OCI notification service topic OCID:

  Usage:

    al-config -T [topic OCID]

  Options:

    -T [topic OCID] OCI notification service topic OCID

Configure OCI CLI profile:

  Usage:

    al-config -u [user OCID] -t [tenancy OCID] -k [key file]

  Options:

    -u [user OCID] OCI User OCID

    -t [tenancy OCID] OCI Tenancy OCID

    -k [key file] from which we obtaion the API private key

    -p [key passphrase file] from which we obtain API key passphrase. Provide

       this if API private key is encrypted. If not provided, user will be

       prompted to enter passphrase.

1 - 1

Post Details

Added on Nov 30 2020
0 comments
316 views