Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9197145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:00:35+00:00 2026-06-17T22:00:35+00:00

Consider the table employee : desc employee; Name Null? Type ————————– ——– ———— EMPLOYEENO

  • 0

Consider the table employee:

desc employee;

Name                       Null?    Type
-------------------------- -------- ------------
EMPLOYEENO                 NOT NULL NUMBER(4)
ENAME                               VARCHAR2(15)
JOB                                 VARCHAR2(15)
MGR                                 NUMBER(4)
HIREDATE                            DATE
SAL                                 NUMBER
COMM                                NUMBER
DEPTNO                              NUMBER(2)

Contains with values of deptno,sal as:

    DEPTNO      SAL
---------- ----------
        10     2450
        10     5000
        10     1300
        20     2975
        20     3000
        20     1100
        20      800
        20     3000
        30     1250
        30     1500
        30     1600
        30      950
        30     2850
        30     1250

Need to update the salary of employees with their department’s average salary.
i.e set every employee’s salary to the departmental average.Is there any solution possible with the group by clause something like

update employee set sal =(select avg(sal) from employee group by deptno) where deptno in(select deptno from employee group by deptno)

So how to query the same.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:00:37+00:00Added an answer on June 17, 2026 at 10:00 pm

    Try this

    UPDATE EMPLOYEE A
    SET SAL = (SELECT AVG(SAL) FROM EMPLOYEE B WHERE B.DEPTNO = A.DEPTNO);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this table (from http://www.tizag.com/mysqlTutorial/mysqlmax.php ): Id name type price 123451 Park's Great Hits
Consider a table or CTE structured like this: Name Num ---- ---- Abc 12
please consider this table: PK_Id Number Year Month Value ------------------------------------------------------------------------- 1 1 2000 5
Consider a fact table of the form: CREATE TABLE Fact1 ( Dim1 int NOT
I have table named Employee with id,first name, middle name, last name as fields.
Consider a table whose job is to store a rating of an object. The
Consider a table like this: | Name | Version | Other | | ---------------------|-------|
Consider create table pairs ( number a, number b ) Where the data is
Consider the table SAMPLE: id integer name nvarchar(10) There is a stored proc called
Consider a SQL Server table defined with a varchar(1) NULL field. It's being used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.