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';

CodePudding user response:

refer to February 16 reply: 3/f
 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';


Merchants rating the field values in table A,

CodePudding user response:

reference 4 floor LaoXiaoJie response:
Quote: February 16 reference 3 floor 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';


Merchants rating the field values in table A,

And then what?

CodePudding user response:

 
The SELECT a. merchants,
A. merchant name.
A. the development manager,
A. duty manager,
, b. [trade]
, b. [total fee]
, b. [merchant ratings]
, b. [mat endowment]
, b. years [statistics]
,
The CONVERT (int, b. [merchant ratings], 2) -
CONVERT (int, b. [merchant ratings], 2)) as merchants rating change
The FROM [HNYS] [dbo]. [merchant information table] a
Join [HNYS] [dbo]. [] data gathered merchants trading b
On a. merchant number=b. merchants,
Where
B. years [statistics]='201910' or
B. years [statistics]='201909'

A field in A table and B fields in A table is not the same, I hope is to do the statistics for A merchant, dimensions, statistics the merchants merchants rating changes, then A merchant A record,

CodePudding user response:

I write of is all "merchant information table" no "merchant transaction data summary", is the main business rating changes, as for the other fields according to the actual demand and associated reading
  • Related