Hcl Technologies 3+ Experienced Sql server Questions




Answers were Sorted based on User's Feedback



Answer / swapna

Hcl Placement Papers | Hcl Interview Procedure |
Hcl Aptitude Questions | Hcl Technical Questions
|Hcl Interview Questions


2 Tables will be there

Namely Employee having columns like Empid,Empname,Salary,Mgrid.

Phone Table having Empid and Phone number.

Based on these some questions like this

1) select all the Employees who does not have phone?

2)Dispaly all managers from table(Manager id is same as Empid)

3)How to know How many tables contain Empno as a column in database?

4)Find duplicate rows in a table or if we have table with one column which
has many records which are not distinct. How to find out the distinct
values from that column and number of times it's repeated?

5) How to delete the rows which are duplicate?(Don't remove both duplicate
records.)

6)How to find the 6th highest salary?

Hcl Placement Papers | Hcl Interview Procedure |
Hcl Aptitude Questions | Hcl Technical Questions
|Hcl Interview Questions

Is This Answer Correct ?    34 Yes 4 No

Answer / suresh

6)How to find the 6th highest salary?

Select MIN(s.salary) FROM
(SELECT TOP 6 salary FROM Employee ORDER BY salary DESC)s

Is This Answer Correct ?    23 Yes 9 No

Answer / chandrasekar

How to know How many tables contain Empno as a column in
database?

SELECT DISTINCT NAME FROM SYSOBJECTS WHERE ID IN (SELECT ID FROM SYSCOLUMNS WHERE NAME = 'EMPNO')

Is This Answer Correct ?    18 Yes 5 No




Answer / raju

1 . select all the Employees who does not have phone?

Select e.Empid,e.Empname
From Employee e
left join Phone p
on p.empid = e.empid where p.phone is null

Is This Answer Correct ?    16 Yes 6 No

Answer / babi

--1)select all the Employees who does not have phone?

SELECT * FROM EMPLOY WHERE EMPID NOT IN(SELECT EMPID FROM PHONE)


--2)Dispaly all managers from table(Manager id is same as Empid)

SELECT * FROM EMPLOY E WHERE E.EMPID=E.MGRID


--3)How to know How many tables contain Empno as a column in database?

SELECT name FROM sys.objects WHERE OBJECT_ID IN (SELECT object_id FROM sys.columns WHERE NAME like 'EMPNO')

--4)Find duplicate rows in a table or
-- if we have table with one column which has many records which are not distinct. How to find out the distinct values from that column and number of times its repeated


SELECT * FROM (
SELECT *,ROW_NUMBER()OVER(PARTITION BY EMPNAME ORDER BY EMPID ) AS NUMS FROM EMPLOY ) A WHERE NUMS>1

CREATE TABLE ONE(ID INT)
INSERT INTO ONE VALUES('1'),('2'),('3'),('4'),('5'),('1'),('2'),('3'),('4'),('5'),('1'),('2'),('3'),('4'),('5')
SELECT ID,COUNT(*) FROM ONE group by ID having COUNT(*)>1



--5) How to delete the rows which are duplicate?(Don't remove both duplicate records.)


WITH TA
AS
(
SELECT EMPID,EMPNAME,ROW_NUMBER() OVER(PARTITION BY EMPNAME ORDER BY SAL DESC ) AS Nums
FROM EMPLOY
)
DELETE FROM TA WHERE Nums>1

WITH AT
AS
(
SELECT *,ROW_NUMBER() OVER(PARTITION BY PHONENUMBER ORDER BY EMPID DESC)AS PHONENUMS FROM PHONE
)
DELETE FROM AT WHERE PHONENUMS>1

--6)how to Find 6th highest sal ?


SELECT MIN(SAL) FROM EMPLOY WHERE SAL IN(
SELECT DISTINCT TOP(6) SAL FROM EMPLOY ORDER BY SAL DESC
)
SELECT TOP 1 SAL FROM (SELECT DISTINCT TOP 6 SAL FROM EMPLOY ORDER BY SAL DESC) EMPLOY ORDER BY SAL

SELECT * FROM
( SELECT DISTINCT TOP 6 SAL , DENSE_RANK() OVER(ORDER BY SAL DESC ) AS RANKS FROM EMPLOY)
EMPLOY WHERE RANKS=6

Is This Answer Correct ?    7 Yes 0 No

Answer / babi

--1)select all the Employees who does not have phone?

SELECT * FROM EMPLOY WHERE EMPID NOT IN(SELECT EMPID FROM PHONE)

Is This Answer Correct ?    8 Yes 2 No

Answer / chandrasekar

SELECT COUNT(DISTINCT NAME)COUNT FROM SYSOBJECTS WHERE ID IN (SELECT ID FROM SYSCOLUMNS WHERE NAME = 'DEPOSITNO') AND NAME NOT LIKE 'SYNCOBJ%'

Is This Answer Correct ?    6 Yes 2 No

Answer / susmita

2)Dispaly all managers from table(Manager id is same as
Empid)




select e.empname from tblemp as e where e.empid in (select distinct mgrid from tblemp)

Is This Answer Correct ?    4 Yes 0 No

Answer / ramesh

How to find the 6th highest salary?

select top 1 salary from
(
select top 6 salary from employee order by salary desc
)a
order by salary

Is This Answer Correct ?    7 Yes 5 No

Answer / vasumathi

3)How to know How many tables contain Empno as a column in
database?

select count(c.name) as Tables,c.name as Empno from
test.sys.tables as t inner join test.sys.columns as c on
c.object_id=t.object_id and c.name='Empno' group by c.name
having count (c.name) > 0

Is This Answer Correct ?    4 Yes 3 No

Post New Answer



More Placement Papers Interview Questions

A Successful Mastek Interview 5 Apr 2007 Bhuwaneswar

1 Answers   Mastek,


The recruitment process of consagous had three rounds. 1. Group discussion 2. Written test 3. Technical interview/ HR The first round was GD. I got the topic “should India break up the friendly ties with Pakistan”. The group had 20 students. After the discussion each student was given a chance to express his/her views on the topic. The second round was written test. The paper was purely technical. It had a total of 50 questions. Out of which 5 questions were subjective. Those questions were: 1. What is RTTI? 2. What is containership? 3. Describe the lifecycle of asp.net page. 4. Why an empty structure occupy 2 bytes memory? 5. What is the difference btw compilation of C++ and C#? The objective questions had some programming questions. Other than that some questions that I remember are: • What is the complexity of binary search algo? • The factor that affects the complexity of an algorithm is a. The maximum amount of memory needed by the algorithm b. The minimum amount of memory needed by the algorithm c. The avg amount of memory needed by the algorithm d. The maximum amount of disc space needed by the algorithm • The class which is used to perform basic console I/O? Ans. System • Which is the first phase of s/w development lifecycle? Ans. Analysis This is all I remember….. The last round was interview. 46 students were selected for the interview. HR questions: • Describe yourself. • Did u held some leadership position in your college (because I mentioned that I was captain in school) • Then they read two aptitude questions(easy ones) and I had to answer them but the condition was that they were not going to repeat the question. • What is your short term and long term goals? • Why your marks decreased in college? • At last they asked about their company. Technical question: • What is the difference between C and C++. • What are access specifiers? • What is a static variable? • How can we define a variable globally? • What is a namespace and assembly? • What is an intermediate language? • Describe your project. • What is the difference between cookies and sessions? And many more……. Finally I got selected after this.

0 Answers   Consagous,


Cts Placement Paper -29 oct 2006 - Hyderabad.

1 Answers   CTS,


WrittenExam At Perot Systems Patnagar 25/04/2007

1 Answers   Perot Systems,


Infosys Experienced Placement Paper - 2006 (Java And J2ee )

2 Answers   Accenture, Wipro, TCS, ABC, Syntel, Infosys, CTS, FIN Infocom,


Aditi placement paper

2 Answers   ADITI,


Caritor placement papers ----------- placement paper 1

2 Answers   Caritor,


HP PLACEMENT PAPERS -------- Placement Paper - 2

2 Answers   HP,


Recent Patterrn Of Sonata Software

1 Answers   Sonata,


placement paper of hpcl

29 Answers   HCL, HPCL,


INFOSYS PAPER - 11 JUN 2006 - CHENNAI

1 Answers   Infosys,


Celstream Placement papers ---------placement paper 1

1 Answers   Celstream,




Categories