Home > database >  SQL statements groupby order has changed
SQL statements groupby order has changed

Time:04-23

 
SELECT ReciveDate InType, CustomName, ElNumber=(stuff ((SELECT ', '+ ElNumber from ElData where IsPrint=' N 'and CustomName=a.C ustomName for XML path ('')), 1, 1, ")), sum (Amount) as Amount, ImportDate, IsPrint from ElData where a IsPrint='N' group by ReciveDate, InType, CustomName, ImportDate, IsPrint

The above is the SQL statement

Yes before polymerization content is
Changzhou
Changzhou
The company
Guangdong
Jinan
Jinan
Jinan
Jiangsu
Chongqing
Chongqing
Yongkang
Yongkang
Nantong
Nantong
Nantong
Yes after polymerization content is
Changzhou
The company
Guangdong

Yongkang
Nantong
Chongqing
Chongqing
Jiangsu


Chongqing with jiangsu mysteriously went behind

CodePudding user response:

Group by multiple fields, according to field successively in the order of sorting, ReciveDate, InType, CustomName, ImportDate, IsPrint

CodePudding user response:

Could you tell me the place name is which the value of the field?
  • Related