0

I need to query the following database - which has a lot of different documents in the 'parameter' field - into a transposed version, where the documents are grouped and the periods are the columns

enter image description here

Like this:

enter image description here

I saw this but in this case the fields must be dinamically added.

Any hints will be much appreciated.

vascobnunes
  • 211
  • 1
  • 10
  • 2
    Sample data is better presented as [formatted text](http://stackoverflow.com/help/formatting). See [here](https://meta.stackexchange.com/questions/81852) for some tips on how to create nice looking tables. –  Feb 06 '20 at 18:09
  • "the fields must be dinamically added" - but then how will your front end make sense of them? Columns have defined names for a reason - theyre like the proeprties of an object. It's all well and good insisting that they have variable names, but it makes it awkward to code for in anything other than a display sense – Caius Jard Feb 06 '20 at 18:35
  • @CaiusJard the goal is to have for a constantly updating list of documents the count of downloads each month. So, I need a query that will generate a table that presents this montlhy data. – vascobnunes Feb 07 '20 at 08:24
  • When we select something from a database the column count is supposed to be fixed and the names and types known. The number of rows is supposed to be variable. DB queries are not supposed to output varying/dynamic columns any more than an OO programming language class Person can have a .Name property today that isn't there tomorrow, or an .Age that is an int `18` today and tomorrow is a string of `"6570 days"` – Caius Jard Feb 07 '20 at 14:07
  • 1
    To this end if you want different numbers of, names of or types of columns out of a db you have to dynamically craft the query the db will run, and pass it for compilation/execution – Caius Jard Feb 07 '20 at 14:08
  • thanks @CaiusJard, that makes sense. I'll try to craft the query dinamically, as you suggest. great tip. thank you! – vascobnunes Feb 10 '20 at 14:33

0 Answers0