Question: I am having a hard time with a dataset that currently have rows showing like the first table, and i would like to change it to look like the bottom table (see picture).

Is this possible in SQL? 

Example data::

![Example data](https://i.stack.imgur.com/UFMho.jpg)

In the case where a customer has not bought a specific product, it should just return null. tablename=dbo.sales

Does anyone know how to transform this?
I hope i have provided enough information to put me in the right direction.
Best, Kirstine

Answer: 
A `DateTime[]` is not an `object[]`; that isn't how array variance works - so: if you pass a `DateTime[]` array to `string.Format`, it isn't using the `Format(string, object[])` overload - you're *effectively* using passing the entire `DateTime[]` as a *single* object to `Format(string, object)`, hence from `Format`'s perspective, you can only use token `0`.

Basically, use:

```cs
var array = new object[] {
       new DateTime(2000, 1, 1),
       new DateTime(2010, 12, 31)
};

```

and it should work.
`var format = "{0:MMM}{1:MMM}";` expects three arguments supplied for `string.Format()` - one for format and two arguments for values. 

Like 

```
string.Format(format, array[0], array[1])

```

another option is to change array from `DateTime[]` to `object[]` array