-
-
-
-
-
Case function
if i have a Customer table with following datacust id custname1 A2 Band cars table with following datacar id cust id Model1 1 Toyota2 1 Honda3 2 Suzukiwhat is the query to give follwing out putcustid cust name model model 11 A Toyota Honda2 ...
-
Create View
Write an SQL statement to create views.
-
-
-
Find the Latest Salary of each Employee in Employer table
How to find the latest salary of each employee in the Employer table?
emp.id sal year month
1001 5000 2015 3
1001 3000 2014 4
1002 4000 2013 3
1003 2000 2013 2 -
What command is used to create a table by copying the structure of another table?
Answer :CREATE TABLE .. AS SELECT commandExplanation : To copy only the structure, the WHERE clause of the SELECT command should contain a FALSE statement as in the following.CREATE TABLE NEWTABLE AS SELECT * FROM EXISTINGTABLE WHERE 1=2;If the WHERE condition is true, then all the rows or rows satisfying the condition will be copied to the new table.
-
-
-
-
-
How to retrieve the 2nd record from a table ?
How to retrieve the 2nd record from a table which has say 1000 records in it. Please answer this without using the row-id? I tried to say a query "select * from table where rowcount=1" which worked well and also "select * from table where rowcount=3" which gave me the result but not when I did the same query "select * from table where rowcount=2" ? why?
-
-
How to change the column name by using ALTER?
I Tried by giving......................... ALTER table table name rename column tocolumn name was changed but it's not giving entire table with altered column name.It's giving only the altered column.
-
-
Difference between joins and subquery?
Why do we use joins, instead subquery has same operation?
-
Display the employee details who joined before 5 days.
Write a query to display the employee details who joined before 5 days.
SQL Interview Questions
Ans