ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
Table student containing 2 columns,Join date,Employee name.
Under join date 4 rows r ter =1-jan-2008,2-feb-2008,3-mar-
2008,4-feb-2008.Under Employee name 4 difeerent names 
jaison,robin,binoy,rahul
 
Result set is,
 Table containing 4-column name=jan,feb,mar,april,,beneath 
these months count is given as 1,2,1,0 means these counts 
representing number of emplooyees joined in a month(january 
1employee,february 2 employee,march 1 employee,april 0 
employee)

Can you give me the required sql query
 Question Submitted By :: Prg
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Table student containing 2 columns,Join date,Employee name. Under join date 4 rows r ter =1-jan-2008,2-feb-2008,3-mar- 2008,4-feb-2008.Under Employee name 4 difeerent names jaison,robin,binoy,rahul Result set is, Table containing 4-column name=jan,feb,mar,april,,beneath these months count is given as 1,2,1,0 means these counts representing number of emplooyees joined in a month(january 1employee,february 2 employee,march 1 employee,april 0 employee) Can you give me the required sql query
Answer
# 1
Hi dude, If u use SQLSERVER 2005 this will help u.......
-------------------------------------------------------

Create table student (studName varchar(50), doj smalldatetime)
insert into student values('Ganesh','05/26/2008')
insert into student values('Ramesh','03/26/2008')
insert into student values('Dinesh','03/26/2008')
insert into student values('Suresh','04/26/2008')

Select * from student

SELECT 'Students Admission by Monthwise',[3] AS March,[4] AS April,[5] AS May
FROM( 
		SELECT	studName,
				Month(doj) monthname 
		FROM	student
	) A
PIVOT
(
	COUNT(studname)
	FOR monthname in
		([3],[4],[5])
) AS PVT
 
Is This Answer Correct ?    10 Yes 1 No
Soorai Ganesh
 
  Re: Table student containing 2 columns,Join date,Employee name. Under join date 4 rows r ter =1-jan-2008,2-feb-2008,3-mar- 2008,4-feb-2008.Under Employee name 4 difeerent names jaison,robin,binoy,rahul Result set is, Table containing 4-column name=jan,feb,mar,april,,beneath these months count is given as 1,2,1,0 means these counts representing number of emplooyees joined in a month(january 1employee,february 2 employee,march 1 employee,april 0 employee) Can you give me the required sql query
Answer
# 2
SELECT Sum([1]) AS Jan, Sum([2]) AS Feb, Sum([3]) AS Mar,Sum([4]) as Apr,Sum([5]) as May,Sum([6]) as Jun,

Sum([7]) as Jul,Sum([8]) as Aug,Sum([9]) as Sep,Sum([10]) as Oct,Sum([11]) as Nov,Sum([12]) as Dec

FROM (SELECT Month(JoinDate) as Mon

FROM AAA) ps

PIVOT

(Count(Mon) FOR Mon IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) AS pvt

group by [1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12]
 
Is This Answer Correct ?    1 Yes 0 No
Prg
 
 
 
  Re: Table student containing 2 columns,Join date,Employee name. Under join date 4 rows r ter =1-jan-2008,2-feb-2008,3-mar- 2008,4-feb-2008.Under Employee name 4 difeerent names jaison,robin,binoy,rahul Result set is, Table containing 4-column name=jan,feb,mar,april,,beneath these months count is given as 1,2,1,0 means these counts representing number of emplooyees joined in a month(january 1employee,february 2 employee,march 1 employee,april 0 employee) Can you give me the required sql query
Answer
# 3
select datename(mm,doj), count(studname) from student group 
by doj
 
Is This Answer Correct ?    0 Yes 0 No
Pradip Jain
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
What is the differecne between equi-join and inner-join and natural join..Is there any difference or all are same? Microsoft2
how to find out the repeated value from table using groupby function?  3
how insert selected column only ? Robert-Half2
What is the basic functions for master, msdb, tempdb databases? CSC2
Anyone please explain me the concept of Serialization?  3
What about UPDATESTATISTICS ? Intelligroup2
Can store procedure call by user define function in SQL server? HCL6
How to find out name of all employees who has salary less than 200 Rs.?  7
How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ........ in the emp database plz mail the answer @ mak2786@gmail.com Oracle18
what is a cursor and what is its use?  1
hi, how to match retrieve the unmatched records from 2 tables in which we dont have any primary key. example : table1 has 1,2,3,4,5 and table2 has 1,2,3,4,5,6,7,8,9,10 and i want the numbers from 6 to 10 to be displayed and should not come as null. i need the numbers. please reply as soon as possible.  2
Explain Active/Active and Active/Passive cluster configurations?  1
Lets say due to N/W or Security issues client is not able to connect to server or vice versa. How do you troubleshoot?  1
PC(code, model, speed, ram, hd, cd, price) Find the hard drive sizes that are equal among two or more PCs. APX2
Hello all, I have data like :- year amt 2004 10 2005 20 2006 30 Now i want output as:- 2004 2005 2006 10 30 60 but i have to use here group by on year.So, i need a single query within that i can find.  2
Would it be a good idea to create an index on a table that always contains 10 records? Why or why not?  3
What is difference between Triggers and store procedure?  2
How To Change Column Ordinal Position in SQL Server 2005 using Query i.e I Want To Add Column at Particular Ordinal Position in SQL Server 2005  2
syntax for deleting the database in T SQL  4
what are three different authentications to connect linked servers? CitiGroup1
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com