sql-server - 查找过去 1 小时内更新的行数的脚本
问题描述
该脚本确实为我提供了更改行的列表,但我还需要确保更改的行数应等于过去 1 小时内更新的行数,这将使我在验证时更加舒适。
这是给我更改行列表的代码。如果我没记错的话,除了第一个选择语句中不在第二个选择中的所有行之外。我只是想知道如何检查在最后一小时更新的行数,当我在下面运行这个查询时,它必须与行数匹配。
Select [Accounting_Period_ID]
,[Policy_Number]
,[Risk_ID]
,[Product_ID]
,[Inception_Date_ID]
,[Effective_Date_ID]
,[Expiration_Date_ID]
,[Cancellation_Date_ID]
,[Reinstate_Date_ID]
,[Policy_Source_System_ID]
,[Risk_Geo_ID]
,[Risk_Profile_ID]
,[Policy_Status_ID]
,[Agency_ID]
,[Limit_Selection_ID]
,[Written_Premium_MTD]
,[Written_Premium_ITD]
,[Fees_MTD]
,[Fees_ITD]
,[Commission_MTD]
,[Commission_ITD]
,[Earned_Premium_MTD]
,[Earned_Premium_ITD]
,[In_Force_Count]
,[New_Business_Count]
,[Renewed_Count]
,[Cancelled_Count]
,[Reinstated_Count]
,[Dwelling_Limit]
,[Other_Structures_Base_Limit]
,[Other_Structures_Extended_Limit]
,[Other_Structures_Total_Limit]
,[Contents_Limit]
,[Additional_Living_Expense_Limit]
,[Liability_Limit]
,[Medical_Limit]
,[Total_Insured_Value]
,[Replacement_Value]
,[AOP_Deductible]
,[Days_in_Force]
,[Earned_House_Years]
,[Cancellation_Entry_Date_ID]
,[Reinstate_Entry_Date_ID]
,[Seq]
,[Inserted_Date]
,[Inserted_By]
,[Last_Updated_Date]
,[Last_Updated_By]
,[Insurance_score]
,[Rewrite_Count]
,[Entry_Date_ID] from Datamart.Policy.Fact_Monthly_Policy_Snap_20190403
where Policy_Source_System_ID = 8
EXCEPT
Select [Accounting_Period_ID]
,[Policy_Number]
,[Risk_ID]
,[Product_ID]
,[Inception_Date_ID]
,[Effective_Date_ID]
,[Expiration_Date_ID]
,[Cancellation_Date_ID]
,[Reinstate_Date_ID]
,[Policy_Source_System_ID]
,[Risk_Geo_ID]
,[Risk_Profile_ID]
,[Policy_Status_ID]
,[Agency_ID]
,[Limit_Selection_ID]
,[Written_Premium_MTD]
,[Written_Premium_ITD]
,[Fees_MTD]
,[Fees_ITD]
,[Commission_MTD]
,[Commission_ITD]
,[Earned_Premium_MTD]
,[Earned_Premium_ITD]
,[In_Force_Count]
,[New_Business_Count]
,[Renewed_Count]
,[Cancelled_Count]
,[Reinstated_Count]
,[Dwelling_Limit]
,[Other_Structures_Base_Limit]
,[Other_Structures_Extended_Limit]
,[Other_Structures_Total_Limit]
,[Contents_Limit]
,[Additional_Living_Expense_Limit]
,[Liability_Limit]
,[Medical_Limit]
,[Total_Insured_Value]
,[Replacement_Value]
,[AOP_Deductible]
,[Days_in_Force]
,[Earned_House_Years]
,[Cancellation_Entry_Date_ID]
,[Reinstate_Entry_Date_ID]
,[Seq]
,[Inserted_Date]
,[Inserted_By]
,[Last_Updated_Date]
,[Last_Updated_By]
,[Insurance_score]
,ISNULL([Rewrite_Count],0) Rew
,[Entry_Date_ID] from Datamart.Policy.Fact_Monthly_Policy_Snap
where Policy_Source_System_ID = 8
解决方案
DATEADD(hh,-1,GETDATE()) 为您提供实际时间减去 1 小时。您可以将其与 Last_Updated_Date 进行比较。Count(*) 为您提供行数。
推荐阅读
- python - 重新组合 Python 列表项/组织给定数据
- google-directory-api - 使用 users.photos.get 获取照片
- ios - 您如何为 iOS 调用本机拨号程序以拨打 911
- c++ - 为什么我的 QSortFilterProxyModel 在与 QStandardItemModel 一起使用时会向我的 TreeView 添加额外的空白行?
- sql - 返回 SQL Server 中重复计数的 4x4 命名列和行
- python - 每当我发送 brew-coffee 请求时,我的 TeaMaster9001 都会以代码 418 进行响应
- c# - 如何更改 TokenEndpointPath
- python - 如何在数据框中将 -0.0 值替换为 0.0 值?
- openshift - 部署在 OpenShift 中的 ansible-tower 在哪里存储 git 存储库克隆?
- javascript - Discord 帐户创建日期问题 / discord.js