1 2 2
我有一个表,它有一些特殊的数据安排,其中有28-31列对应于一系列唯一id的月份的日期。我要做的是用实际的日期值把它变成更可行的格式。我的表如下所示:
DECLARE @Month VARCHAR(3)
SET @Month = 'NOV'
一个选择是使用JSON来"动态地";取消数据透视
Select A.[ID]
,A.[Status]
,[Date] = datefromparts(2022,11,[key])
,Value
From YourTable A
Cross Apply (
Select [Key]
,[Value]
From OpenJson( (Select A.* For JSON Path,Without_Array_Wrapper ) )
Where [Key] not in ('ID','Status')
) B
结果
ID Status Date Value
111 Active 2022-11-01 A
111 Active 2022-11-02 2
111 Active 2022-11-03 3
111 Active 2022-11-04 4
111 Active 2022-11-05 Z
相关内容
- 如何自动计算INSERTET DATE -当前日期
- 计算date在某个范围内出现的次数
- 迭代seq.Date对象,带有for循环,用R填充矩阵以计算人年
- SQL Day Count两个日期之间的计算,使用两个表T1 = Days, T2 = Week Ending Date
- date-fns格式React中的日期和年龄计算问题
- 从Date()计算前几个月重复一个月
- date-fns如何计算最小年龄?
- 在SQL中使用相对列名值计算DATE值
- 在PostgreSQL中,计算ID在单个Date列中出现的平均持续时间(时间间隔)
- 通过筛选另一个列"Date"来计算列中的某些值
- 根据从日期选取器输入的'Date of Birth'显示计算的年龄(以年为单位)
- 计算在 PostgreSQL 中合并到单个列的特定'date'的累积总和
- 使用 $date->diff 在 php 中计算年龄返回错误值
- 数组列出<Date>如何按月/年计算出现次数
- JS Date对象计算发送时间是否在一小时内
- 我有一个数据帧表,其中有一个ticker列和一个date列.我想计算一下相应日期的股票价格
- 如何计算SQL中两个日期之间的年,月,日的持续时间/年龄?InstituitionDate和NextDate有"date"数据类型吗?
- 如何将此数组传递给html.erb文件中的javascript函数,而不使用erb计算Date.UTC
- 如何在PostgreSQL中计算DATE差
- Oracle:计算DATE类型列的日分数
最新更新
- SwiftUI:Foreach in List - 有什么优势?
- 如何加载所有转储附加的字典在python pickle?
- Jmeter语言 - 当前活动线程
- Java作用域问题:try-catch块,解析字符串到日期
- 如何在主应用中获得UWP应用服务的通知?
- 复选框的定位
- 弹簧启动-采用与2个ymls不同的属性
- Symfony 5.3+翻译提供商Crowdin不更新本地文件
- 从文本文件(.txt)中读取字节数组
- 如何下载完整的雅典娜查询结果到CSV文件
- pyspark:在执行join - restrict相同列名选择时设置别名
- 如何在Eclipse RCP中隐藏/删除Preferences对话框中的导入/导出按钮
- 在自定义jackson反序列化器中以响应式方式从db加载实体
- 使用RestSharp从API返回JSON数据
- OAuth同意屏幕不显示正确的AppName
- 使用ByRef更新记录集字段
- 提取多个XML文件中所有标签之间的文本,并将提取的文本复制到csv文件中
- 在Laravel和Vue之间共享数据的糟糕方式
- 可以在Azure Devops中找到需求文本文件
- 如何在tensorflow keras中引用ground truth变量?
- Json解析并分配给DTO
- 如何通过不重复结果来正确地循环一个范围
- 给出零最优值的AMPL程序
- 再次出现身份验证问题,GCP源存储库使用publickey
- 打印添加到数据库的记录数有问题
- 如何插入一行到一个表在sql是完全相同的另一个表,但只有一个列不同?
- 如何在jupyter notebook中导入两个或多个包?
- 对product类型的访问器进行泛型迭代
- 如何在 react 中"remember"昂贵的递归函数中先前计算的值?
- 在eclipse IDE上使用Tomcat服务器在本地机器上修复eclipse上的编译错误,我能做些什么?
热门标签:
javascript python java c# php android html jquery c++ css ios sql mysql arrays asp.net json python-3.x ruby-on-rails .net sql-server django objective-c excel regex ruby linux ajax iphone xml vba spring asp.net-mvc database wordpress string postgresql wpf windows xcode bash git oracle list vb.net multithreading eclipse algorithm macos powershell visual-studio image forms numpy scala function api selenium