Question

1. Answer the questions with respect to the table below. users gender id name age occ_id city_id John 25 M 3 1 2. Sara 20 F 3(b) [2.5+2.5+5) Write query to make a copy of users table known as users_new. Write query to insert all columns of users

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

1.

CREATE TABLE users_new LIKE users;

2.

INSERT INTO users_new SELECT * FROM users;

3.

ALTER TABLE users ADD salary INT;

UPDATE users, occupation
SET salary =
(
case
when occupation.name = 'Software Engineer' then 80000
when occupation.name = 'Accountant' then 75000
when occupation.name = 'Pharmacist' then 90000
end
)
WHERE users.occ_id= occupation.id;

Add a comment
Know the answer?
Add Answer to:
1. Answer the questions with respect to the table below. users gender id name age occ_id...
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 UK         Female             5000...

  • 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...

  • Assume the table below is a client table: Client ID Client Name Client Services Client City...

    Assume the table below is a client table: Client ID Client Name Client Services Client City Client Revenue Client type (active/inactive) 1 BK Associates Commercial Toronto 230,000 active 6 Bick Industrial Dallas 679,000 inactive 19 TPH Government Atlanta 986,000 active 12 Crow Industrial Phoenix 126,000 inactive 56 TX Electric Industrial Portland 564,000 active 42 GRB Government Omaha 437,000 inactive 98 LB&B Commercial Toronto 990,000 active 44 H&P Commercial Denver 122,000 active You are asked to implement a C# console application...

  • In pgAdmin, i have a employee table( name, salary) like this    Name salary TOM 3000...

    In pgAdmin, i have a employee table( name, salary) like this    Name salary TOM 3000 Jack 2000 Mike 6000 Susan 3000 Chris 5000 Nancy 5000 If i do select name, salary, densen_rank() over (order by salary desc ) as AA from table ,it'll return me a table like this Name Salary AA Mike 6000 1 Chris 5000 2 Nancy 5000 2 Suan 3000 3 Tom 3000 3 Jack 2000 4 Is there anyway i can write a query and...

  • Please answer the following questions bles Charts SmartArtReview Paragraph AaBbCcDdEe Normal Name: ID Name: ID: Question...

    Please answer the following questions bles Charts SmartArtReview Paragraph AaBbCcDdEe Normal Name: ID Name: ID: Question (1) For the following periodic signal, (5p 2) Write os os5 2WY 1) Determine the Fourier series coefficient as an b Sec 1 Pages 1 of 4 Words: 63 of 83 L 25

  • Using c++ write a program using a class that has   data members ID#,NAME, SALARY, YEAR_HIRED. This...

    Using c++ write a program using a class that has   data members ID#,NAME, SALARY, YEAR_HIRED. This program must 1) write 10 blank records to a random access file. You must enter data for 4 of these records. 2) allow the user to output the name, salary, hire_date for a selected record 3) allow the user to change the name, salary, or hire_date for a selected record. 4) allow the user to input a complete record to replace one of the...

  • Using the following data to create various queries below. Database is Pensacola Healthcare Facility(FacilityID, SuborgID, Addr)...

    Using the following data to create various queries below. Database is Pensacola Healthcare Facility(FacilityID, SuborgID, Addr) Provider(ProviderID, FirstName, LastName, NPI, FacilityID) Patient(PatientID, FirstName, LastName, Addr) Appointment (AppointmentID, ApptTime, ProviderID, PatientID, FacilityID) 1. Write a query displaying all patients 2. Write a query showing all appointments for a patient with an ID of 2. 3. Write a query in DESC order of Addr for all facilities. 4. Write a query showing all Providers with name LIKE Smith. 5. Write a query...

  • 1. Given the table above, write an SQL Query that will select only those individuals that...

    1. Given the table above, write an SQL Query that will select only those individuals that scored 800 or higher, sorted by last name in ascending order. 2. Given the table above, write an SQL Query that will add a new entry for John Smith with a score of 834. The field id is auto incrementing. 3. Given the data below, write an SQL Query that will delete any values where the score is below 740. id Fname Lname Score...

  • Part II: Group-by and subqueries The following questions use the Spy and Sailors database. Write the...

    Part II: Group-by and subqueries The following questions use the Spy and Sailors database. Write the SQL for the following queries. 1) List the sailor id and name for each sailor who has reserved two different red boats. Make sure that each sailor id/name is listed at most once. You must use group by/having. 2) List the missions and their status for each team. 3) For each country in agent, list the country and the count of agents in the...

  • 1.Write a PHP function that generates a random email. 2.Write a PHP function that generates a...

    1.Write a PHP function that generates a random email. 2.Write a PHP function that generates a random password given the length as a parameter. 3. Run a query that will generate a database named lab4 b. 4.Run a query that will create a table named users, the table will only have three columns, email TEXT and password TEXT, ID INTEGER NOT NULL AUTO_INCREMENT. ID will be the primary key that will be generated for us automatically based on the record...

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