The PIVOT command is not standard SQL command, it is supported only by some DBMS, SQLite and MySQL are not among them.
But you can make a similar view of the data using a script that will create a table view with the desired number of columns and rows.
This is not often ordered, I don’t have a ready-made simple example. All I can say is that you will need three SQL queries: 1) get a list of headers for rows 2) get a list of headers for columns 3) get data.
Key methods:
1) add Column for Row Names
try
Grid.Columns.Add(TNxTextColumn);
except
end;
Grid.Columns[0].Width := 40;
Grid.FixedCols := 1;
Grid.Columns[0].Color := clbtnFace;
2) add a column for data
try
Grid.Columns.Add(TNxTextColumn);
except
end;
Grid.Columns[Grid.Columns.count-1].Header.Caption := ColData.FieldByName('name').asString;
Grid.Columns[Grid.Columns.count-1].Color := clWhite;
Grid.Columns[Grid.Columns.count-1].Width := 40;
3) add a row
Grid.AddRow;
Grid.Cells[0, Grid.RowCount-1] := RowData.FieldByName('name').asString;
4) fill the cell with data.
Grid.Cells[col, row] := CellData;
Визуальное программирование:
блог и
телеграм-канал.