0

例如,我有下表中的数据

表顺序

-----------------------------------------
   id_order    no_order       order_date
-----------------------------------------
     1         0000001       12-01-2013
     2         0000002       15-01-2013
-----------------------------------------

表 item_order

--------------------------------------------------
   id_item_order       id_order      order_name
--------------------------------------------------
       1                 2           Product 1
       2                 2           Product 2
       3                 2           Product 3
       4                 2           Product 4
--------------------------------------------------

然后我想显示来自数据库的数据加入如下

--------------------------------------------------
  id_item_order     order_name       no_order
--------------------------------------------------
      1             Product 1        0000002 A
      2             Product 2        0000002 B
      3             Product 3        0000002 C
      4             Product 4        0000002 D
--------------------------------------------------

如何根据表序中item_order和id_order相关的数据量显示no_order后面的字符“A-n”?

请帮我。谢谢你

4

2 回答 2

1

我不知道 oracle 但我尝试使用 SQL 并且效果很好

select TIO.id_item_order,TIO.order_name,[TO].no_order + char(ROW_NUMBER() 
 OVER (order by id_item_order )+64) as no_order 
 from  
 TableItemOrder TIO inner join TableOrder [TO] on [TO].id_order=TIO.id_order

它对我有用

于 2013-01-21T09:54:22.227 回答
1

用于测试的SQL Fiddle

select i.id_item_order, i.id_order,
        o.no_order || chr(rownum + 64) as no_order
from item_order i
inner join "order" o on o.id_order = i.id_order;
于 2013-01-21T10:10:56.907 回答