Home > database > How in SQL according to the calculation of a value two worth the difference in the same column
How in SQL according to the calculation of a value two worth the difference in the same column
Time:10-01
Masters, excuse me, I in the same list below according to the time field, recorded the rating of each merchant, such as 6, and so on, I hope based on the time field to determine the change of a merchant ratings, such as in September and October, the merchants of rating changes, could you tell me how to write SQL to this?
SELECT [HNYS] [dbo]. [merchant information table]. Merchants, Name of merchants, The development manager, Duty manager, , total volume,, total poundage,, [merchant ratings] , mat endowment,And years [statistics] , (the CONVERT (int, [merchant ratings], 2) - CONVERT (int, [merchant ratings], 2)) as merchants rating changes The FROM [HNYS] [dbo]. [merchant information table] Join [HNYS] [dbo]. [merchant transaction data summary] On [HNYS] [dbo]. [merchant information table] merchant number=[HNYS] [dbo] [merchant transaction data summary]. Merchants, Where [statistical year]='201910' or [statistical year]='201909'
CodePudding user response:
And found out is like that, I hope is found out a data, is the same business,
CodePudding user response:
SELECT the CONVERT (INT, a. [merchant ratings], 2) - CONVERT (INT, b. [merchant ratings], 2)) AS merchants rating change The FROM merchants information table a The JOIN merchant information table b ON a. merchant number=b. merchants, AND a. years [statistics]='201910' AND b. years [statistics]='201909';