You asked how to access the alias of one subquery in another ... with a quick glance, this is one way to do this using two "simulated tables". You can use select statements similar to a table. Not sure if this is your best solution, but should help you on the right track.
SELECT testav.*, testt.* FROM ( SELECT av.testid as id, max(decode(av.name, 'longitude', stringvalue, NULL)) as longitude, max(decode(av.name, 'latitude', stringvalue, NULL)) as latitude FROM test_av av GROUP BY av.testid ) testav, (SELECT t.id as id, ((ACOS( SIN(16.15074 * 3.141592653 / 180) * SIN(t.latitude * 3.141592653 / 180) + COS(16.15074 * 3.141592653 / 180) * COS(t.latitude * 3.141592653 / 180) * COS((-22.74426 - t.longitude)*3.141592653 / 180) )*6373)) as distance FROM test t ) testt WHERE testav.id = testt.id and testt.distance <= 100
Another subquery method simply adds two selections for two columns of latitude and longitude and refers to an external query by alias. It seems like it will be poor performance, but Oracle does a great job with this type of query. There is no need for a single column group. I would think about returning an empty string, not null if you don't need it. I'm not sure if Oracle will like zero or not for the "else" situation. I suppose it should work for you this way.
SELECT id, ACOS(..snipped details..)*6373) as distance, (SELECT max(decode(av.name, 'longitude', stringvalue, NULL)) FROM test_av WHERE test_av.testid = av.id) as longitude, (SELECT max(decode(av.name, 'latitude', stringvalue, NULL)) FROM test_av WHERE test_av.testid = av.id) as latitude FROM test_av av WHERE av.distance <= 100
Adding a final comment. The second request will not get what the OP requires, since the longitude and latitude are used in the calculation. This is one example of a subquery, but not a solution to the OP question. Sorry if he is misleading anyone.