Home > database >  How to realize the lines at the same time to collect more data in the column
How to realize the lines at the same time to collect more data in the column

Time:09-16

Rt: because the data is at the same time to collect more data and branch, currently intends to transfer line column, but the result is below, is there any way to the same time together?

CodePudding user response:

Direct GROUP BY no,

The SELECT TIMESTAMP, MAX (fan air volume 2) AS the fan air volume 2, MAX (fan air volume 1) AS the fan air volume 1
FROM the TABLE
GROUP BY TIMESTAMP

CodePudding user response:

reference 1st floor RINK_1 response:

No good ah, air volume 1 and 2 is not listed, is according to the value of the TAGNAME retrieved

CodePudding user response:

refer to the second floor chailang326 response:
Quote: refer to 1st floor RINK_1 response:

No good ah, the air volume 1 and 2 is not listed, it is according to the value of the TAGNAME retrieved the


That you put your query result set as a derived table, then GROUP BY taking the maximum, or transfer line column before the RAWDATA first table according to the TIMESTAMP and maximize TAGNAME grouping, turn again try,

CodePudding user response:

You'll have to put your data and table structure post and see, you are not available in this case the

CodePudding user response:

The
Hello World reference 4 floor, response:

The SQL statement: SELECT * FROM (
SELECT [TIMESTAMP], CAST (TAGNAME AS NVARCHAR (MAX)) AS TAGNAME, [VALUE] FROM [HH2]. [! Root]. [TFXT] [RAWDATA]) p PIVOT
(MAX (VALUE) FOR TAGNAME (IN 1 air fan, fan air volume 2)) AS PVT
The ORDER BY CAST (PVT. [TIMESTAMP] AS NVARCHAR (MAX))

Data with links to the server, I will export data for all tests, to be set up under the table structure;

Link: https://pan.baidu.com/s/1m-rxHnKCQiINBet_je_hyg extraction code: h7g5 copy after this paragraph open baidu cloud mobile phone App, operation more convenient

CodePudding user response:

By the way, remind, cannot use the select cast, the current test data is only 2 so is simpler, the test data is changing, number and name will be different,

CodePudding user response:

Without a great god can answer to solve?
  • Related