I get data from a DBF file and put it in a DataTable, the thing is I just want to get the distinct data, for example:
Column1
a
b
c
b
a
And the DataTable should be populated just with:
Column1
a
b
c
Is there any way to make this happen, or get it around??
connDBF.Open();
string jobData1 = "SELECT * FROM HREQDETM.DBF";
OdbcCommand cmd1 = new OdbcCommand();
cmd1.CommandText = (jobData1);
OdbcDataAdapter dbAdapter1 = new OdbcDataAdapter(jobData1, connDBF);
DataSet dtSet1 = new DataSet();
dbAdapter1.Fill(dtSet1);
DataTable dbTable1 = dtSet1.Tables[0];
The thing is, I’m doing a migration and the data is in DBF files, I want something quick because I’m going to run the script in my computer and send the data through a VPN in SQL statement
Just add
DISTINCTto your queryIf you want distinct values for Column1 but still the rest of the columns in the table you have to decide which data to get when two or more values are group together as one for Column1.
Example
So when the duplicates for
ais removed what do you want to display in column2:1or2?You can write:
I would recommend reading some more about Group by and aggregates