需要使用存储过程的出勤表 [英] Need attendance table using stored procedures

查看:117
本文介绍了需要使用存储过程的出勤表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的桌子有这样的两列

Hi,

I am having table with two columns like this

eid    date
-----------
01     04/12/09
02     03/04/09



现在我需要这样的输出



Now I need output like this

eid    1    2   3   4  5   6  7   8 ----------  31

01     a    a   a   p  a   a  a   a             a 

02     p    p   p   p



我需要使用存储过程,并且必须在存储过程中提供empid的参数

然后,如果我给出empid,则必须在一个月内获得当天或缺席的时间.



I need to use stored procedures and have to give parameter of empid there in stored procedure

Then if I give empid I have to get present or absent of that day in a month.

推荐答案

如果您使用的是SQL Server 2005或更高版本,则可以使用PIVOT TSQL来获得交叉表结果.

如果是SQL 2000或更早版本,则必须创建一个动态sql并执行它以获取结果.

[
If you are using SQL Server 2005 or above, you can use the PIVOT TSQL to achieve the crosstab result.

In case of SQL 2000 or earlier, you would have to create a dynamic sql and execute it to get the result.

[External Link on solution]


这篇关于需要使用存储过程的出勤表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆