特定修改日期的最小值(最大值)和最大值(最大值)

时间:2022-06-01 18:05:47

How to Get a Min and Max column value for the Modified date

如何获取修改日期的最小和最大列值

I want to select top and bottom column value for the particular date.

我想为特定日期选择顶部和底部列值。

Table:

 **DATE**     **MODIFIED DATE**  **VALUE**

03:02:2009  04:02:2009  100
03:02:2009  04:02:2009  200
03:02:2009  04:02:2009  400
04:02:2009  05:02:2009  150
04:02:2009  05:02:2009  200
04:02:2009  05:02:2009  500

In my Table - Date Column and Value column is there

在我的表 - 日期列和值列中

How can i get min(value) and Max(value) for the particular modified date?

如何获得特定修改日期的最小值(值)和最大值(最大值)?

Modified date should be n number of date, suppose am giving from this modified date to this modifed date

修改日期应为n个日期,假设从此修改日期到此修改日期

I want output like this

我想要像这样的输出

MODIFIED DATE   MIN VALUE   MAX VALUE
04:02:2009  100 400
05:02:2009  150 500

2 个解决方案

#1


SELECT ModifiedDate, MIN(Value), MAX(Value)
FROM TheTable
GROUP BY ModifiedDate
ORDER BY ModifiedDate

edit re comment; it isn't clear how you want to calculate ModifiedDate, but for a simple formula, just inline it:

编辑评论;目前尚不清楚如何计算ModifiedDate,但对于一个简单的公式,只需内联它:

SELECT DATEADD(day, 1, Date) AS [ModifiedDate], MIN(Value), MAX(Value)
FROM TheTable
GROUP BY DATEADD(day, 1, Date)
ORDER BY DATEADD(day, 1, Date)

For something more complex, anything from:

对于更复杂的东西,来自:

  • table variables (@table)
  • 表变量(@table)

  • temporary tables (#table)
  • 临时表(#table)

  • sub-queries
  • etc

#2


Marc Gravell,

Table

DATE    VALUE
22:02:2009  200
22:02:2009  400
22:02:2009  100
24:02:2009  250
24:02:2009  400
24:02:2009  800

(Select Date, … from table)

(从表格中选择日期,...)

While executing the above query, below mentioned table is displaying

执行上述查询时,显示下面提到的表

DATE    MODIFIED DATE   VALUE
22:02:2009  23:02:2009  200
22:02:2009  23:02:2009  400
22:02:2009  23:02:2009  100
24:02:2009  25:02:2009  250
24:02:2009  25:02:2009  400
24:02:2009  25:02:2009  800

Here leave the date column; exactly I need min (value) and max (value) for the Modified Date

这里留下日期栏;我需要修改日期的min(value)和max(value)

Output I need like this

输出我需要这样

DATE    MN VALUE    MAX VALUE
22:02:2009  200 100
24:02:2009  250 800

Note: Don’t evaluate the column value, only I need top value and bottom value for the particular date.

注意:不要评估列值,只需要特定日期的最高值和最低值。

#1


SELECT ModifiedDate, MIN(Value), MAX(Value)
FROM TheTable
GROUP BY ModifiedDate
ORDER BY ModifiedDate

edit re comment; it isn't clear how you want to calculate ModifiedDate, but for a simple formula, just inline it:

编辑评论;目前尚不清楚如何计算ModifiedDate,但对于一个简单的公式,只需内联它:

SELECT DATEADD(day, 1, Date) AS [ModifiedDate], MIN(Value), MAX(Value)
FROM TheTable
GROUP BY DATEADD(day, 1, Date)
ORDER BY DATEADD(day, 1, Date)

For something more complex, anything from:

对于更复杂的东西,来自:

  • table variables (@table)
  • 表变量(@table)

  • temporary tables (#table)
  • 临时表(#table)

  • sub-queries
  • etc

#2


Marc Gravell,

Table

DATE    VALUE
22:02:2009  200
22:02:2009  400
22:02:2009  100
24:02:2009  250
24:02:2009  400
24:02:2009  800

(Select Date, … from table)

(从表格中选择日期,...)

While executing the above query, below mentioned table is displaying

执行上述查询时,显示下面提到的表

DATE    MODIFIED DATE   VALUE
22:02:2009  23:02:2009  200
22:02:2009  23:02:2009  400
22:02:2009  23:02:2009  100
24:02:2009  25:02:2009  250
24:02:2009  25:02:2009  400
24:02:2009  25:02:2009  800

Here leave the date column; exactly I need min (value) and max (value) for the Modified Date

这里留下日期栏;我需要修改日期的min(value)和max(value)

Output I need like this

输出我需要这样

DATE    MN VALUE    MAX VALUE
22:02:2009  200 100
24:02:2009  250 800

Note: Don’t evaluate the column value, only I need top value and bottom value for the particular date.

注意:不要评估列值,只需要特定日期的最高值和最低值。