peter

peter

  • NA
  • 320
  • 0

Get unique column value based on a returned list of rows

Jan 5 2022 1:51 PM

  I have the following SQL query that at present returns duplicate [Fuel] column values.While i want unique Fuel values to bind to control.

The additional columns are necessary additions for the search function later.

i.e Petrol,Diesel,Electric

I tried to use the Group By instead of using DISTINCT but it would not allow to Group on only one column i.e Fuel and when applied to all columns it returned distinct row with duplicate Fuel values. If anyone knows how to return only unique rows based upon Fuel types that would work for my application.

Thanks

 SELECT DISTINCT [CategoryID],Products.[Fuel],[Brand],[ProductSize] FROM [Products] WHERE ([CategoryID] = @CategoryID AND Products.[Category] = @Category) and Products.Fuel is not null
  


Answers (2)