自已的sql server练习小记
Posted 咖啡无眠的随笔
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自已的sql server练习小记相关的知识,希望对你有一定的参考价值。
print getdate();
print datediff(year,‘1987-09-13‘,getdate())
select * from CallRecords
select top 5 *,‘通话时间(秒)‘=DATEDIFF(s,CallRecords.StartDateTime,CallRecords.EndDateTime)
from CallRecords order by ‘通话时间(秒)‘ desc
select ‘jian‘,* from CallRecords
select SUM(t1.通话时间) from(
select 通话时间=DATEDIFF(s,CallRecords.StartDateTime,CallRecords.EndDateTime) from CallRecords where TelNum like ‘0%‘
) as t1
print datepart(year,getdate())
select top 3 CallerNumber,
通话时间=sum(datediff(s,startDateTime,endDatetime))
from CallRecords
where DATEDIFF(mm,StartDateTime,‘2010-07-12‘)=0
group by CallerNumber
order by 通话时间 desc
select top 3 CallerNumber,
通话次数=COUNT(CallRecords.Id)
from CallRecords
where DATEDIFF(mm,StartDateTime,‘2010-07-12‘)=0
group by CallerNumber
order by 通话次数 desc
以上是关于自已的sql server练习小记的主要内容,如果未能解决你的问题,请参考以下文章