Barclays Interview Questions | Query I

Question

You have got some data in the Table 1 and Table 2

Table 1

Id Last_Name First_Name Title
E0011 Verma Nikita Technician
E0012 Jordan Chris HR
E0013 Samson Nil Assistant
E0014 Smith Joe In charge

 

Table 2

Id Salary
E0013 80,000
E0012 65,000
E0011 70,000
E0014 75,000

 

Write a SQL query to create a Table 3 that contains the following columns- Id, First_Name, Last_Name, Salary

(Hint- The columns should be in the prescribed order)

in progress 0
Dhruv2301 55 years 5 Answers 3139 views Great Grand Master 1

Answers ( 5 )

  1. CREATE TABLE table3
    AS
    SELECT t1.id , t1.first_name ,t1.last_name ,t2.salary
    FROM
    table1 t1 JOIN table2 t2 ON t1.id = t2.id

  2. CREATE table table3
    as
    select table1.id , table1.first_name ,table1.last_name ,table2.salary
    FROM
    table1 join table2 on table1.id = table2.id;

  3. select Id, First_Name, Last_Name, Salary
    from table1 join table2 using(id)

  4. CREATE TABLE Table3 AS
    SELECT T1.id , T1.first_name ,T1.last_name ,T2.salary FROM
    table1 T1 Inner join table2 T2 ON T1.id = T2.id

  5. CREATE Table 3 as
    SELECT T1.firstname ,T1.lastname,T2.Salary
    from Table T1 JOIN Table 2
    ON T1.id =T2.id;

  6. CREATE Table 3 as
    SELECT T1.firstname ,T1.lastname,T2.Salary
    from Table T1 JOIN Table 2
    ON T1.id =T2.id;

Leave an answer

Browse
Browse