All of the online crossbar conversion is a one-size-fits-all, reference value is not, and only suitable for that data volume fixed student score table of the vertical transformation, but when really encountered large data volume conversion is not feasible, the following describes a relatively flexible large amount of data in the horizontal table conversion:
Table structure:
as shown in, where index_id ends with a 0 representation of the service name, ending with 1 for the device RAC name, and 2 at the end of the device state.
below we need to put a set of 0,1,2 end of the separate display as the service name, the device RAC name, the device status of the table header row of data, multiple sets of 0,1,2 end of the display of multiple rows of data.
SQL executes as follows:
Selectindex_id/Ten asNmmMax( CaseMoD (index_id,Ten) when 0 ThenMon_indexdata.valueElse "' End) Cluster_Name,Max( CaseMoD (index_id,Ten) when 1 ThenMon_indexdata.valueElse "' End) Sys_name,Max( CaseMoD (index_id,Ten) when 2 ThenMon_indexdata.valueElse "' End) State fromMon_indexdatawhereUid= '110100224' andindex_id>3010000 Group byindex_id/Ten
The main rule is to group by the 10 and the second-to-last number of inde_id.
SQL implementation Vertical table variable horizontal table