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
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 |
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 |
Answer / pradip jain
select datename(mm,doj), count(studname) from student group
by doj
Is This Answer Correct ? | 2 Yes | 0 No |
What is the use of keyword with encryption.
Explain syntax for viewing trigger?
How to enable tcp/ip protocol on a sql server?
What are the different types of columns types constraints in the sql server?
What is the difference between sql server 2000 object owner and sql server 2005 schema? : sql server database administration
what are file groups?
What does it mean to manipulate data?
Why use triggers?
What is a join in sql? What are the types of joins?
What are the steps you can take to avoid “deadlocks”?
I am having table Title with TITLE id,Author ID, Publiser ID , table AUTHOR with Author ID, Author Name, table PUBLISER with Pub ID, Pub name Here hot to find out the publiser id who have relesed the books of patriticular author?
event classes in sql server