t-sql查询 [英] t-sql query

查看:83
本文介绍了t-sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


这是我第一次来这里,我想解决下面给出的问题。任何见解都会很棒


我有2个观点,想要计算两个日期之间(在同一列下)的天数。 500行。


数据是这样的


查看1


14 ab 01/03 / 2007

14 ab 11/03/2007

14 ab 23/04/2007

14 ab 30/04/2008


查看2


14 ab xyz

13 ac avc

12 ad see

1 az qwa


我想要的结果


14 ab 01/03 / 2007年2月(从月初的第一天开始)

14 ab 11/03/2007 10

14 ab 23/04/2007。

14 ab 30/04/2008。

Hi Everyone,

This is my first time here and I want to tackle the given below problem. any insight would be great

I have 2 views and want to calculate days in between 2 dates(under same column) for approx. 500 rows.

Data is like this

view 1

14 ab 01/03/2007
14 ab 11/03/2007
14 ab 23/04/2007
14 ab 30/04/2008


view 2

14 ab xyz
13 ac avc
12 ad see
1 az qwa


Result i want

14 ab 01/03/2007 2 (minus from the first day of month)
14 ab 11/03/2007 10
14 ab 23/04/2007 .
14 ab 30/04/2008 .

推荐答案

datediff函数返回两个日期之间的差异,无论你想要多少个。天,月,年,小时,分钟,秒
The datediff function returns the difference between two dates in whatever multiple you want. Days, months, years, hours, minutes, seconds



datediff函数返回两个日期之间的差异,无论你想要多少个。天,月,年,小时,分钟,秒
The datediff function returns the difference between two dates in whatever multiple you want. Days, months, years, hours, minutes, seconds




这件事我知道,但我想知道如何使用2个视图存在多行以及如何添加一些功能以捕获第一天的第一天,如果第一个记录日不是那样。



This thing I know but I want to know that how I can use that with 2 views where multiple rows exist and how to add some functionality to catch the first day of month if first record day is not that.


我不知道字段名称所以我会做一些,你可以适应。根据你想要的结果,看不到誓言2,所以我会忽略这篇文章。

查看1

ID AL DTE

14 ab 2007年1月3日

14 ab 11/03/2007

14 ab 23/04/2007

14 ab 30/04/2008

I dont know the field names so I will make some up and you can adjust to suit. From your desired result a cant see vow view 2 comes in so I will ignore for this post.
View1
ID AL DTE
14 ab 01/03/2007
14 ab 11/03/2007
14 ab 23/04/2007
14 ab 30/04/2008

展开 | 选择 < span class =codeDivider> | Wrap | 行号


这篇关于t-sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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