How to re-use result for SELECT, WHERE and ORDER BY clauses?

前端 未结 3 968
半阙折子戏
半阙折子戏 2020-12-11 05:34

The following query returns the venues near us (lat: 62.0, lon: 25.0) inside whose radius we fall in ordered by distance:

SELECT *, 
     earth_distance(ll_t         


        
3条回答
  •  生来不讨喜
    2020-12-11 05:56

    You can also create stand alone or packaged function and use it in your queries:

     SELECT *
       FROM ...
      WHERE distance <= your_function()  -- OR your_package_name.your_function()
     ORDER BY ...
    

    You can use your function in select:

    Select your_function() 
      From your_table...
     Where  ...
    

提交回复
热议问题