1

This is table1. I need to arrange the following data hoizontally.

id      date    value
1       22/08   500
2       22/08   400
3       23/08   300
4       23/08   200
5       24/08   100
6       24/08   700

Output table:

date    1       2       3       4       5       6
------|-------|------|-------|-------|------|--------
22/08   500     400
------|-------|------|-------|-------|------|--------
23/08                   300     200
------|-------|------|-------|-------|------|--------
24/08                                   100     700
-----------------------------------------------------

I am trying to make the query but failed to get the output table.

dipak dutta
  • 274
  • 2
  • 13
  • Alternatively, consider handling issues of data display in the presentation layer/application-level code, assuming you have that (e.g. a simple PHP loop acting upon an ordered array). – Strawberry Nov 15 '17 at 17:42
  • In order to produce an execution plan, the SQL language really needs to be able to know the number and datatypes of the columns up front, at query compile time. When the columns depend on data in the rows, that's not immediately possible. You're stuck doing this in two steps and writing dynamic SQL. It's just the way SQL works. – Joel Coehoorn Nov 15 '17 at 17:49

0 Answers0