如何使用sql中的条件动态创建一个月的天数 [英] How to create days Dynamically for a month with the conditions in sql

查看:89
本文介绍了如何使用sql中的条件动态创建一个月的天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  CREATE   TABLE  employee_active_on_proj 

EmpName varchar 50 ),
ProjectName varchar 50 ),
startofproject datetime
EndOfProject < span class =code-keyword> datetime
);



这里有一行数据



 插入 进入 employee_active_on_proj '  JOhn''  Projet 1''  03/04/2015''  2015年4月14日'

insert into employee_active_on_proj ' JOhn' ' Projet 2'' 16 / 04/2015'' 24/04/2015'





我的输出应该基于输入使用存储过程的月份和年份







==================================== ===================================

Empname 01/04/2015。 .03 / 04/2015 14/04/2014 .... 31/04/2015



============== ================================================== =======

JOhn N / A ACTIVE项目结束



============ ================================ ============================

解决方案

这个怎么样?

在SQL Server中生成日期表 [ ^ ]

CREATE TABLE employee_active_on_proj
(
    EmpName varchar(50),
    ProjectName varchar(50),
    startofproject datetime,
    EndOfProject datetime
);


And here is one row of data

insert into employee_active_on_proj values('JOhn','Projet 1','03/04/2015','14/04/2015')

insert into employee_active_on_proj values('JOhn','Projet 2','16/04/2015','24/04/2015')



My output should be based on the inputs Month and year using stored procedure



=======================================================================
Empname 01/04/2015 .. 03/04/2015 14/04/2014 .... 31/04/2015

=======================================================================
JOhn N/A ACTIVE Project ends

========================================================================

解决方案

How about this?
Generate Date Table in SQL Server[^]


这篇关于如何使用sql中的条件动态创建一个月的天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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