0

私の場合、指定された日付期間の間に PercentAvailability 列の値を 0 から 100 に更新する更新クエリを実行したいと考えています2012-10-28 03:31:01 to 2012-10-28 08:31:01。次の図を参照してください。

ここに画像の説明を入力

指定した日付の間に上記のデータを更新するクエリを実行するにはどうすればよいですか?

注: この問題を抱えている ApplicationID が多数あるため、すべての ApplicationID に対してクエリを実行するにはどうすればよいでしょうか。

4

1 に答える 1

5

このクエリを使用

update your_table
set PercentAvailability = 100
where PercentAvailability = 0
and [DateTime] between '2012-10-28 03:31:01' and '2012-10-28 08:31:01'

または、特定のものに対してのみ同じものを更新したい場合は、次のApplicationIDようにします

update your_table
set PercentAvailability = 100
where PercentAvailability = 0
and [DateTime] between '2012-10-28 03:31:01' and '2012-10-28 08:31:01'
and ApplicationID = 1235

または複数のApplicationID場合

update your_table
set PercentAvailability = 100
where PercentAvailability = 0
and [DateTime] between '2012-10-28 03:31:01' and '2012-10-28 08:31:01'
and ApplicationID in (1235, 1236, 1237)

または大きな数の場合、またはApplicationIDサブクエリを実行できます

update your_table
set PercentAvailability = 100
where PercentAvailability = 0
and [DateTime] between '2012-10-28 03:31:01' and '2012-10-28 08:31:01'
and ApplicationID in (select ApplicationID from another_table where somecondition)
于 2012-10-31T18:55:24.367 に答える