0% found this document useful (0 votes)
26 views

SQL Related Questions answers

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

SQL Related Questions answers

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

SQL Related Questions :-

1) What is the differences between delete and truncate?


Ans: The DELETE command is used to delete specified rows(one or more).
While this command is used to delete all the rows from a table.
2) What is the differences between IN and Exists?
Ans : IN works like a multiple OR operator. So, it exempts us to write OR
multiple times in a query.
Exists returns TRUE value if matching is found.
3) What are the types of operations in SQL?

1. Arithmetic Operators

2. Comparison Operators

3. Logical Operators->and,or,not,between,any

4. What is the differences between Primary key and unique contraints?


Ans Primary key will not accept NULL values whereas Unique key can
accept NULL values.
5)What is the difference between Rank ( ) and Row numbers ( )?
Ans RANK and DENSE_RANK are deterministic in this case, all rows with the
same value for both the ordering and partitioning columns will end up with an
equal result, whereas ROW_NUMBER will arbitrarily (non deterministically)
assign an incrementing result to the tied rows.
6)How to Retrieve the first 5 characters from the string?
Ans SELECT SUBSTRING(original string, starting value, end value) AS
ExtractString
7)Name different types of possible joins in SQL with a description?

 Ans INNER JOIN (also known as a ‘simple’ JOIN). This is the most
common type of JOIN.
 LEFT JOIN (or LEFT OUTER JOIN)
 RIGHT JOIN (or RIGHT OUTER JOIN)
 FULL JOIN (or FULL OUTER JOIN)
 Self joins and cross joins

8) Write a query to count the number as Rows from two different tables?
Ans SELECT COUNT (distinct t1.id) + COUNT (distinct t2.id) AS
totalRows FROM firstTable t1, secondTable t2

9)Write a query to count the numbers of columns from two different tables?
Ans SELECT count(*) as No_of_Column FROM information_schema.columns
10)Write a query to get the date format dd-mm-yyyy?
Ans select to_char(yourdate,'DD/MM/YYYY' )

11) Write a query a name starts with “S” and end with “H”?
Ans select * from employees where ename like ‘s%h’

12) Types of joins with examples?


Ans
SELECT StudentCourse.COURSE_ID, Student.NAME, Student.AGE FROM
Student
INNER JOIN StudentCourse
ON Student.ROLL_NO = StudentCourse.ROLL_NO;

SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
LEFT JOIN table2
ON table1.matching_column = table2.matching_column;

SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
RIGHT JOIN table2
ON table1.matching_column = table2.matching_column;

SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
FULL JOIN table2
ON table1.matching_column = table2.matching_column;
13)Differences between IN and BETWEEN operators
Ans Both of these operators are used to find out the multiple values from the table.
Differences between these operator is that the BETWEEN operator is used to
select a range of data between two values while The IN operator allows you to
specify multiple values.
14) Types of operators in SQL?
 Ans Arithmetic operator
 Comparison operator
 Logical operator

15) Write a SQL query to get the date and year?


Ans select to_char(hire_date,'DD/yyyy') from employees

16) Joins and types of joins?


17) Python operators and explain them.
Ans
1. Arithmetic Operators
2. Logical Operators
3. Comparison Operators
4. Bitwise Operators
5. Assignment Operators
6. Membership Operators->in,not in
7. Identity Operators->is,is not
18) Explain python functions.
19) What is an array?
Ans: An array is a group of similar elements or data items of the same
type collected at contiguous memory locations
20) What is SSIS ?
Ans SQL Server Integration Services (SSIS) is a popular and mature tool for
performing data movement and cleanup operations. In the Microsoft
ecosystem, SSIS is one of the most common extract, load, and transform
(ETL) tools in use today. SSIS is powerful and configurable, yet surprisingly
easy to use.

21) How to make SSIS dynamic ?


Ans It is basically to follow 5 steps (again, detailed in the link):
1. Create a project parameter and configuring the project's connection manager
with the project parameter
2. Deploy the project to the SSIS catalog in SQL server
3. Create an environment in the SSIS catalog, along with a variable
4. Link the environment to the project and the variable with the parameter
5. Execure the package using the environment
22) Get the count of rows from a table?
Ans SELECT Count(*) FROM tblcustomer
1. Use COUNT() function.
2. Combining SQL Server catalog views.
3. Using sp_spaceused stored procedure.
4. Using SQL Server Management studio.

You might also like