2017년 1월 9일 월요일

Getting the max of a column and displaying the row's value from another column


I'm trying to create an app which will select the highest value of column A and display the value of column B in that same row.

Is there a more efficient way to do this than to check every single value one by one?

--
SELECT B FROM <tableid> ORDER BY A DESC LIMIT 1

-- 
Thank you, but I think I must have missed something.

I have attached a block of my code. I wish to take the 3 highest values in the HITS column and display the NAME of those rows. For some reason, my result is just the first 3 names in my table, by order of rowid, not the value of HITS.


orderbyproblem.PNG 표시 중

-- 
your screenshot looks fine
you also can send a SELECT NAME, HITS FROM <tableid> ORDER BY HITS DESC LIMIT 3 to the table to find out, what's going on

-- 
Thank you so much! That fixed it. When I pulled the list of names it didn't order them unless I also pulled the numbers to order it by.

My only problem is that now I wish to remove certain items from the list.

The result I have from the fusion table is:

((Amanda catcher 25)(Marissa right 18)(Cara left 99))

What I'm trying to do is checking if any of the names appear in a label I'm using on the app. If the name appears then that person's information should be removed from the list, but when I do it, it says that I am trying to remove item with index 0.

listremovingproblem.PNG 표시 중

-- 
use Do it to debug your blocks, see also tip 4 here
and remember, you are working with a list of lists...

-- 
When I use Do it on the index in list block it gives me a zero but I know that the value of batter1.text appears in the list. Is this because that is not the only value in that row?

The value of batter1.Text is Gina, but the row with Gina is (Gina right 13).

-- 

댓글 없음:

댓글 쓰기