Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Answers were Sorted based on User's Feedback



Table student containing 2 columns,Join date,Employee name. Under join date 4 rows r ter =1-jan-200..

Answer / soorai ganesh

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 ?    12 Yes 1 No

Table student containing 2 columns,Join date,Employee name. Under join date 4 rows r ter =1-jan-200..

Answer / prg

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 ?    2 Yes 0 No

Table student containing 2 columns,Join date,Employee name. Under join date 4 rows r ter =1-jan-200..

Answer / pradip jain

select datename(mm,doj), count(studname) from student group
by doj

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What are the new features introduced in SQL Server 2000? What changed between the previous version of SQL Server and the current version?

0 Answers   Accenture,


What are statistics?

0 Answers  


Do you know exporting and importing utility?

0 Answers  


You have to store user responses of ‘yes’ and ‘no’ what kind of data type is best suited for this task?

0 Answers  


Where can you add custom error messages to sql server?

0 Answers  


Table - Products has number of products as below Productid ProductName 1 iPhone 2 iPad 3 BlackBerry Table - SalesPersonProduct has the below records Salespersonid productid S1 1 S1 2 S1 3 S2 1 S3 2 Write a SQL query that returns the number of sales for each product

2 Answers  


What is the correct order of the logical query processing phases?

0 Answers  


How to query multiple tables jointly?

0 Answers  


Explain the characteristics of a transaction server for example atomicity, consistency, isolation, durability?

0 Answers  


how to improve the speed of SQL database server and how to avoid dead lock?

1 Answers   TCS,


How to determine the service pack currently installed on SQL Server?

4 Answers   HCL,


What do you mean by cardinality?

0 Answers  


Categories