如何在oracle中获取最长的2个合适的字段

How to get the longest 2 appropriate fields in oracle

我了解如何从oracle中的一列中获取最长的字段,如下所示:

select name from daTable
where length(name) =
(select max(length(name)) from daTable)

但现在我有 2 个表:一个用于 car_make,其中有一列 make_description(如 Nissan),另一个用于 car_model,其中有一列 model_description (像提达)。我怎样才能从 2 个不同的表中得到最长的字段:car_make 和他适当的 car_model?

这是我的表的结构:

Car_make: id_make , make_description
Car_model: id_model, model description,P_id_make  

(其中 car_model 中的 P_id_make 是 car_make 中的 id_make)

您可以这样连接列

  select a.make_description  || ' ' || b.model_description as name 
  from Car_make a 
  INNER JOIN Car_model b on a.id_make = b.P_id_make
  where length( a.make_description  || ' ' || b.model_description  ) =
  ( select max(a.make_description  || ' ' || b.model_description) 
  from Car_make a 
  INNER JOIN Car_model b on a.id_make = b.P_id_make)