Question

SQL/Oracle EMPLOYEE Table ID NAME GENDER SALARY COUNTRY 1 Mark Male 5000 USA 2 John Male...

SQL/Oracle

EMPLOYEE Table

ID

NAME

GENDER

SALARY

COUNTRY

1

Mark

Male

5000

USA

2

John

Male

4500

Canada

3

Pam

Female

5500

USA

4

Sara

Female

4000

Canada

5

Todd

Male

3500

Canada

6

Mary

Female

5000

UK

7

Ben

Male

6500

UK

8

Elizabeth

Female

7000

USA

9

Tom

Male

5500

UK

10

Ron

Male

5000

USA

Given the EMPLOYEE table above, write a query that would produce the output below.

COUNTRY    GENDER     Total Salary
---------- ---------- ------------
Canada     Female             4000
Canada     Male               8000
UK         Female             5000
UK         Male              12000
USA        Female            12500
USA        Male              10000
NULL       Female            21500
NULL       Male              30000
51500

9 rows selected.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per requirement submitted above kindly find below solution.

SQL query :

select country,gender,sum(Salary) "Total Salary" from employee
group by rollup(gender,country)
order by country,gender;

Explanation :

  • This SQL query will get the country , gender and sum of salary from employee.

NOTE :PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
SQL/Oracle EMPLOYEE Table ID NAME GENDER SALARY COUNTRY 1 Mark Male 5000 USA 2 John Male...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • SQL/Oracle EMPLOYEE Table ID NAME GENDER SALARY COUNTRY 1 Mark Male 5000 USA 2 John Male...

    SQL/Oracle EMPLOYEE Table ID NAME GENDER SALARY COUNTRY 1 Mark Male 5000 USA 2 John Male 4500 Canada 3 Pam Female 5500 USA 4 Sara Female 4000 Canada 5 Todd Male 3500 Canada 6 Mary Female 5000 UK 7 Ben Male 6500 UK 8 Elizabeth Female 7000 USA 9 Tom Male 5500 UK 10 Ron Male 5000 USA Given the EMPLOYEE table above, write a query that would produce the output below. COUNTRY    GENDER     Total Salary ---------- ---------- ------------ Canada     Female             4000 Canada     Male               8000 Canada     NULL              12000...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT