选择具有条件的所有不同行。

编程入门 行业动态 更新时间:2024-10-27 20:28:16
本文介绍了选择具有条件的所有不同行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

对你们许多人来说可能很简单。但我正在努力解决这个问题。 我有一个像这样的简单表。我想选择每个姓名有一条记录的记录,这些记录具有最近的日期。结果应如下所示。 名称日期 ---- ---- NAME1 2008-02 -12 06:32:14.380 NAME2 2004-03-14 06:35:03.420 NAME3 2002-07-20 06:23:21.463 NAME2 2001-03-01 04:33:24.356 NAME1 1999-03-14 02:35:04.410 NAME2 2005-01-10 06:55 :42.430 NAME2 2002-09-09 03:22:27.378 NAME3 2003-03-30 06:11:13.120 NAME3 2001 -04-10 06:03:45.454 结果 ------ NAME1 2008-02-12 06 :32:14.380 NAME2 2005-01-10 06:55:42.430 NAME3 2003-03-30 06:11:13.120 如何实现这一目标?

It may be simple for many of you. But I am stuggling with this. I have a simple table like this. I want to select the records with one record per each name which has recent date. the result should be like given below. NAME DATE ---- ---- NAME1 2008-02-12 06:32:14.380 NAME2 2004-03-14 06:35:03.420 NAME3 2002-07-20 06:23:21.463 NAME2 2001-03-01 04:33:24.356 NAME1 1999-03-14 02:35:04.410 NAME2 2005-01-10 06:55:42.430 NAME2 2002-09-09 03:22:27.378 NAME3 2003-03-30 06:11:13.120 NAME3 2001-04-10 06:03:45.454 RESULT ------ NAME1 2008-02-12 06:32:14.380 NAME2 2005-01-10 06:55:42.430 NAME3 2003-03-30 06:11:13.120 How can I achieve this?

推荐答案

许多人可能很简单您。但我正在努力解决这个问题。 我有一个像这样的简单表。我想选择每个姓名有一条记录的记录,这些记录具有最近的日期。结果应如下所示。 名称日期 ---- ---- NAME1 2008-02 -12 06:32:14.380 NAME2 2004-03-14 06:35:03.420 NAME3 2002-07-20 06:23:21.463 NAME2 2001-03-01 04:33:24.356 NAME1 1999-03-14 02:35:04.410 NAME2 2005-01-10 06:55 :42.430 NAME2 2002-09-09 03:22:27.378 NAME3 2003-03-30 06:11:13.120 NAME3 2001 -04-10 06:03:45.454 结果 ------ NAME1 2008-02-12 06 :32:14.380 NAME2 2005-01-10 06:55:42.430 NAME3 2003-03-30 06:11:13.120 我怎样才能做到这一点? It may be simple for many of you. But I am stuggling with this. I have a simple table like this. I want to select the records with one record per each name which has recent date. the result should be like given below. NAME DATE ---- ---- NAME1 2008-02-12 06:32:14.380 NAME2 2004-03-14 06:35:03.420 NAME3 2002-07-20 06:23:21.463 NAME2 2001-03-01 04:33:24.356 NAME1 1999-03-14 02:35:04.410 NAME2 2005-01-10 06:55:42.430 NAME2 2002-09-09 03:22:27.378 NAME3 2003-03-30 06:11:13.120 NAME3 2001-04-10 06:03:45.454 RESULT ------ NAME1 2008-02-12 06:32:14.380 NAME2 2005-01-10 06:55:42.430 NAME3 2003-03-30 06:11:13.120 How can I achieve this?

展开 | 选择 | Wrap | 行号

你好 我的要求与原始查询,只有我的日期列格式如下: JAN08 MAR07 NOV06 AUG07 是否可以使用类似于您的解决方案的SQL,而不是使用日期表为每个月和年组合分配价值? 非常感谢! Hello I have the same requirements as the original query, only my date column format is as such: JAN08 MAR07 NOV06 AUG07 Is it possible to use an SQL similar to your solution rather than having a date table which assigns value to each of the month&year combinations? Thanks very much!

你好 我有与原始查询相同的要求,只有我的日期列格式如下: JAN08 MAR07 NOV06 AUG07 是否可以使用与您的解决方案类似的SQL,而不是使用可为其分配值的日期表每个月份和年份的组合? 非常感谢! Hello I have the same requirements as the original query, only my date column format is as such: JAN08 MAR07 NOV06 AUG07 Is it possible to use an SQL similar to your solution rather than having a date table which assigns value to each of the month&year combinations? Thanks very much!

尝试使用DATEPART函数来实现结果。

Try using DATEPART function to achieve your results.

更多推荐

选择具有条件的所有不同行。

本文发布于:2023-07-15 10:11:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1110599.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:同行   条件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!