相关Miscrosoft SQL [英] Related to Miscrosoft SQL

查看:82
本文介绍了相关Miscrosoft SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要更改新流程的过程更改
SLTax表中每个Unique_ID的活动表中的记录
具有以下特征:

加入SLTax.Unique_ID = Activity.Unique_ID

SLTax标准:

Covge_Eff_Dt> ''2008年12月31日''
Payto代码IN(``1216AA'',``1772AA'')
Payb_status =``O''

活动标准:

Check_ID = 10
对于max.check_date,Is_Present = 0


为符合上述条件的每个Unique_ID在活动中插入新记录
符合条件:
Check_ID = 10
User_ID = 45
日期=当前日期
Is_Present = 1


以下查询用于获取数据,但我无法检索它并插入.查询如下

A process change that necessitates the insertion of a new
record in the Activity table for each Unique_ID in the SLTax table
having the following characteristics:

JOIN on SLTax.Unique_ID = Activity.Unique_ID

SLTax Criteria:

Covge_Eff_Dt > ''12/31/2008''
Payto code IN (''1216AA'', ''1772AA'')
Payb_status = ''O''

Activity Criteria:

Check_ID = 10
For max.check_date, Is_Present = 0


INSERT a new record in Activity for each Unique_ID meeting the above
criteria:
Check_ID = 10
User_ID = 45
Date = current date
Is_Present = 1


The follwoing query is used to fetch the data but i am not able to retrive it and Insert. the Query is as follows

SELECT     dbo.Activity.*
FROM         dbo.Activity INNER JOIN
                      dbo.SLTax ON dbo.Activity.Unique_ID = dbo.SLTax.Unique_ID
WHERE     ('Check_Date' IN
                          (SELECT     MAX('Check_Date')
                            FROM          Activity)) AND (dbo.Activity.Check_ID = 10) AND (dbo.Activity.Is_Present = 'o') AND (dbo.SLTax.Cvge_Eff_Dt > CONVERT(DATETIME, 
                      '2008-12-31 00:00:00', 102)) AND (dbo.SLTax.Payto_Cd IN ('1216AA', '17772AA')) AND (dbo.SLTax.Payb_Status = 'o')



我可以就此



can I get help regarding this

推荐答案

获得帮助吗?在使用聚合函数时,您应该应用分组依据"和从句".


希望此链接对您有所帮助:

http://blog .sqlauthority.com/2007/07/04/sql-server-definition-comparison-and-difference-between-having-and-where-clause/ [
You should apply Group By and Heaving Clause while working with aggregate funcitons.


Hope this link will Help you :

http://blog.sqlauthority.com/2007/07/04/sql-server-definition-comparison-and-difference-between-having-and-where-clause/[^]


SELECT     dbo.Activity.*
FROM         dbo.Activity INNER JOIN
                      dbo.SLTax ON dbo.Activity.Unique_ID = dbo.SLTax.Unique_ID
WHERE     (dbo.Activity.Check_ID = 10) AND (dbo.Activity.Is_Present = '0') AND (dbo.SLTax.Cvge_Eff_Dt > CONVERT(DATETIME, '2008-12-31 00:00:00', 102)) AND
                      (dbo.SLTax.Payto_Cd IN ('1216AA', '17772AA')) AND (dbo.SLTax.Payb_Status = 'O') AND ('Check_Date' IN
                          (SELECT     MAX('Check_Date')
                            FROM          Activity))


这篇关于相关Miscrosoft SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆