|
Post by jayantharmj on Dec 16, 2023 1:10:51 GMT
How to use RANK function please help me.(Apart from this my project is working smothly).Here lev2 is int value.I have attached error message as an image. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- my code ----------------- SimpleSQL.SimpleDataTable dt = dbManager.QueryGeneric("SELECT stuid,pl_name,pl_gr,lev2, RANK ()OVER(ORDER BY lev2 DESC)Rank FROM Maths_players "); int rowIndex = 1; foreach (SimpleSQL.SimpleDataRow dr in dt.rows) { outind.text += dr["stuid"] + "\n"; outname.text += dr["pl_name"] + "\n"; outgr.text += dr["pl_gr"] + "\n"; outser.text += rowIndex.ToString() + "\n"; outmarks.text +=dr["lev2"] + "\n"; outrank.text+=dr["Rank"] + "\n"; rowIndex++; } Attachments:
|
|
|
Post by jayantharmj on Dec 16, 2023 13:51:19 GMT
Or any other method to get the rank.ORDER BY does not give the result correctly if there are 2 students with same marks. Waiting for your answer....
|
|
|
Post by echo17 on Dec 17, 2023 13:04:21 GMT
One issue I see is that you are using the keyword "Rank" for your rank alias. You should use something different, perhaps "rank_value": SELECT stuid, pl_name, pl_gr, lev2, RANK () OVER (ORDER BY lev2 DESC) rank_value FROM Maths_players
I was able to successfully set up a rank query and it worked in SimpleSQL. Here is my test table data: And my code: var sql = "SELECT val, RANK () OVER (ORDER BY val DESC) val_rank FROM rank_test"; SimpleSQL.SimpleDataTable dt = dbManager.QueryGeneric(sql);
foreach (var dr in dt.rows) { Debug.Log(dr["val"] + " (" + dr["val_rank"] + ")"); }
Gives the results: If you are still having trouble, I'll need to see an example of your project. Please see this FAQ: link
|
|
|
Post by jayantharmj on Dec 17, 2023 17:04:44 GMT
It is working out side unity (in sqlite browser and windows form application) even with out changing the word Rank.But inside Unity same error message appear. I changed as you said ......... SimpleSQL.SimpleDataTable dt = dbManager.QueryGeneric("SELECT stuid,pl_name,pl_gr,lev2, RANK()OVER(ORDER BY lev2 DESC) Rank_col FROM Maths_players "); Here Rank_col is a column name where rank numbers appear
|
|
|
Post by jayantharmj on Dec 17, 2023 23:38:28 GMT
I want something like attached image.
|
|
|
Post by echo17 on Dec 18, 2023 12:01:44 GMT
If it is working outside of the editor, then it sounds like you made some changes to your database, but didn't propagate them to the working directory. That can be done by setting the "Override if exists" to true in the inspector. Note that this will overwrite any changes you have made at runtime. If you don't want to overwrite the changes, then you will need to make an upgrade path in code. Please see this FAQ: linkRank works in SimpleSQL, so there is something about your project setup or code that is causing the issue. Without seeing your project, it is hard to diagnose this. Again, if you would like me to take a look at your project, please see this FAQ: link Note that I will only look at projects if you can provide an invoice number.
|
|
|
Post by jayantharmj on Dec 19, 2023 22:05:03 GMT
Thanks I will try
|
|
|
Post by jayantharmj on Dec 21, 2023 0:25:49 GMT
I created new fresh project to send you for error checking .Wow then it worked perfectly with the same code But I could not solved it when I tried with my existing educational project .That one I built for Android . So I changed the platform of this newly created testing project. Even then it worked perfectly.
|
|
|
Post by echo17 on Dec 21, 2023 13:28:53 GMT
It sounds like what I suggested last post, that you probably made some changes to your project database, but did not propagate them to the working database. Please see this FAQ: link
|
|
|
Post by jayantharmj on Dec 21, 2023 14:56:30 GMT
Thanks I will check
|
|
|
Post by jayantharmj on Dec 21, 2023 23:05:07 GMT
With Your help I could solve. Thank for your patient support.So the instructions I got from the developer (previous posts on this topic)may help others.
|
|