getting the correct values
Posted: Thu May 26, 2005 12:31 am
I store some values in postgresql in varchar format. The values that I store in the varchar data type are either integer or numeric. I store 6 values for each user. I want to take only 4 greatest values and find their average. For example if store the values 13, 14, 6, 13, 13, 17 and I use this query to get the 4 greatest values,
select value from master where name='$name' desc limit 4;
it returns 6,17,14,13. I have to get 17,14,13,13. How can i do this, and if i store a numeric value like 13.5 the value 17,14,13.5,13 should be fetched.
select value from master where name='$name' desc limit 4;
it returns 6,17,14,13. I have to get 17,14,13,13. How can i do this, and if i store a numeric value like 13.5 the value 17,14,13.5,13 should be fetched.