Guest User

Guest User

  • Tech Writer
  • 58
  • 4.7k

select top six car by fueltype

Mar 10 2022 9:58 AM

Hello 

I want data according to of top-six car by fuel type and using this query

public static string TopSixCarsByFuel(string _fuel)
{
    var _sql = "SELECT TOP(6)ci.car_ID,ci.user_ID,ci.brand,ci.modelType,ci.expectedPrice,ci.transmission,ci.saleCity,ci.modelYear,ci.totalDriven,ci.modelYear,ci.fuelType,ci.color,cd.primaryImage AS primary_Image,cd.imagePath as image_Path FROM CarInfo ci ";
    if (!string.IsNullOrEmpty(_fuel) && _fuel != "")
    {
        _sql += "INNER JOIN CarDetail cd ON ci.car_ID=cd.car_ID WHERE ci.fuelType='" + _fuel + "' AND cd.primaryImage=1 AND adContentType='Good'  AND (ci.isSold<>1 or ci.isSold is null);";

    }
    else
    {
        _sql += "INNER JOIN CarDetail cd ON ci.car_ID=cd.car_ID WHERE cd.primaryImage=1 AND adContentType='Good'  AND (ci.isSold<>1 or ci.isSold is null);";

    }
    return _sql;
}

but didn't get it


Answers (4)