vendredi 13 février 2015

Output as Int row number after order by currency

I'm new with C#. I would like some help finishing the code to execute a query to return the row number after an order by (currency). The table has user (person name) and currency (their amount of points). The query will order the database by currency then return the row number of that user (string input).



Table

user | currency

personname | #



This is what I have so far from googling.



public int overallrank(string user)
{
Int32 count;
String sql = "SELECT chan1.*, ( SELECT COUNT(*) FROM " + channel + " AS chan2 WHERE chan2.currency > chan1.currency ) as ChanRank FROM " + channel + " as chan1 WHERE chan1.user = '" + user +"'";
using (cmd = new SQLiteCommand(sql, myDB))
{
count = (Int32) cmd.ExecuteScalar();
}
return count;
}

Aucun commentaire:

Enregistrer un commentaire