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 Posted / 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 |
Post New Answer View All Answers
Can you explain important index characteristics?
How exceptions can be handled in sql server programming?
What is implicit mode in sql server?
How do we know if any query is retrieving a large amount of data or very little data?
What is an inner join?
Explain datetimeoffset data type in sal server 2008?
What is efficiency data?
On a windows server 2003 active – passive failover cluster, how do you find the node which is active?
How can you append an identity column to a temporary table?
What is tablesample?
How to use subqueries in the from clause in ms sql server?
How to integrate the ssrs reports in application?
In which sql server version report builder introduced?
Explain the use of keyword with encryption. Create a store procedure with encryption?
How to check status of stored procedure in sql server?