Question: I have an issue and I'm unable to resolve it. Have a look at my code.

```
CustomerProductivity.Add(new ChartDataViewModel
{
    Series = new List<string> { "Sales" },
    ChartType = "bar",
    Data = SalesStatistics
        .GroupBy(b => b.CustomerName)
        .Select(g => new ChartDataElement()
        {
            X = g.Key,
            Y = new List<int>() { (int)g.Sum(b => b.Sales) }
        }).OrderByDescending(f=> f.Y).Take(3).ToList(),
    ChartConfig = config
});

```

The scenario is that I want to get the Top 3 Customers with highest sales. But it gives me an error as "At least one object must implement IComparable". Surprisingly, I've tried to order by customer name and it worked fine, but it's not fine if I order by sales.

Answer: 
This is wrong:

```
while ($result25 = mysqli_query ($con,"SELECT * FROM santaterra WHERE Fecha='$today' AND Status='Reserved'"))

```

Your loop will never end as you are doing the same query over and over and over.

You need to do the query once and then fetch rows until there are no more:

```
$result25 = mysqli_query ($con,"SELECT * FROM santaterra WHERE Fecha='$today' AND Status='Reserved'");
while ($row25 = mysqli_fetch_array($result25);) {
  ...

```

Apart from that you should use prepared statements to avoid sql injection and you should use a `JOIN` in sql so that you only have to do one query and not another query in the loop.
your while statement should be:
`while ($row = mysqli_fetch_array($result))`