数码资讯
通过使用MSSQL,组
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
复制代码代码如下所示:
——创建数据库dbtemp
使用dbtemp
创建测试表
(
PID int(1,1)不是空主键,
年的日期,
isfirstsixmonths int默认(0),0表示今年上半年的半年代表一年的下半年
totalcome int
)
插入测试
选择'2007-1-1,0.5
联盟
选择'2007-3-1,0,60
联盟
选择'2007-12-1,1,80
联盟
选择'2008-1-1 ',0100
联盟
选择'2008-12-1 ',1100
从测试中选择*
选择转换(char(4),年120)as'year,
isfirstsixmonths = = 0时isfirstsixmonths半场当isfirstsixmonths = 1下半年结束,
和(totalcome)as'sum'from试验
集团通过isfirstsixmonths,转换(char(4),年120)
选择转换(char(4),年120)as'year,
isfirstsixmonths = = 0时isfirstsixmonths后半场的其他在下半场结束,
和(totalcome)as'sum'from试验
集团通过isfirstsixmonths,转换(char(4),年120)
——删除数据库dbtemp
结果如下:
复制代码代码如下所示:
2007上半年110
2007下半年80
2008上半年100
2008下半年100
——创建数据库dbtemp
使用dbtemp
创建测试表
(
PID int(1,1)不是空主键,
年的日期,
isfirstsixmonths int默认(0),0表示今年上半年的半年代表一年的下半年
totalcome int
)
插入测试
选择'2007-1-1,0.5
联盟
选择'2007-3-1,0,60
联盟
选择'2007-12-1,1,80
联盟
选择'2008-1-1 ',0100
联盟
选择'2008-12-1 ',1100
从测试中选择*
选择转换(char(4),年120)as'year,
isfirstsixmonths = = 0时isfirstsixmonths半场当isfirstsixmonths = 1下半年结束,
和(totalcome)as'sum'from试验
集团通过isfirstsixmonths,转换(char(4),年120)
选择转换(char(4),年120)as'year,
isfirstsixmonths = = 0时isfirstsixmonths后半场的其他在下半场结束,
和(totalcome)as'sum'from试验
集团通过isfirstsixmonths,转换(char(4),年120)
——删除数据库dbtemp
结果如下:
复制代码代码如下所示:
2007上半年110
2007下半年80
2008上半年100
2008下半年100
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。