asked on
string sSelectSQL = "SELECT DISTINCT fname, sname, company, notes FROM Main WHERE sname like '" + snametxt.Text + " %' ORDER BY fname ASC";
SqlCommand oCommand = new SqlCommand(sSelectSQL, oConnection);
oConnection.Open();
oReader = oCommand.ExecuteReader();
DataSet ds = new DataSet();
DataTable dt = new DataTable("Table1");
ds.Tables.Add(dt);
ds.Load(oReader, LoadOption.PreserveChanges, ds.Tables[0]);
datagridview1.DataSource = ds.Tables[0];
oReader.Close();
oConnection.Close();
ASKER
select fname, sname, company, notes
from (
SELECT fname, sname, company, notes,
row_number() over (partition by fname, sname, company order by fname asc) rnum
FROM Main
WHERE sname like '" + snametxt.Text + " %' ) temp
where rnum = 1
ASKER
ASKER
ASKER
Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.
TRUSTED BY
string sSelectSQL = "SELECT fname, sname, company, MAX(notes) FROM Main WHERE sname like '" + snametxt.Text + " %' GROUP BY fname, sname, company ORDER BY fname ASC";