英文:
Extract Minimum date
问题
从“Date”列中,有些单元格包含一个日期,有些包含两个或更多日期。
我想要从“Date”列中的单元格中提取最小的日期,或者如果只有一个日期,则保留该日期。
英文:
I have column Date where some cells have one date, some two or more.
From multiple dates in one cell of the Date column I want to extract minimum date or if it one date then retain the date.
Could someone please help me. Below is the sample.
答案1
得分: 0
你可以尝试使用 STRING_SPLIT 函数。
SELECT Date, MIN(s.value) AS Min_Date
FROM <你的表格> d
CROSS APPLY STRING_SPLIT(d.Date, '|') AS s
GROUP BY Date;
在这里查看演示 here。
英文:
You could try to use STRING_SPLIT function
SELECT Date, MIN(s.value) AS Min_Date
FROM <your table> d
CROSS APPLY STRING_SPLIT(d.Date, '|') AS s
GROUP BY Date;
See demo here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论