【问题标题】:SQL Insert values with subquery and column multiplication带有子查询和列乘法的 SQL 插入值
【发布时间】:2015-06-20 07:56:41
【问题描述】:

我正在尝试将包含列乘法的子查询的值插入到表中。这很好用,但是如果我查询表,它只有 0 个值。有人知道为什么吗?

我的查询是:

create table user_payments
       (payment_stream number(4));

insert into user_payments (payment_stream)
select ct.min_price*s.stream_min as payment_stream
  from users u
       , streaming s
       , content_type ct
       , contract c
       , media_content mc
 where u.user_ID           = s.user_ID 
   and mc.media_content_ID = s.media_content_ID 
   and ct.content_type_ID  = mc.content_type_ID  
   and u.user_ID           = c.user_ID  
   and c.contract_name     = 'Pay as you go';

如果我单独查询 select 查询,我会得到预期的结果,但是,一旦将行插入到表中,所有值都是 0。

感谢您的帮助!

【问题讨论】:

    标签: select insert subquery


    【解决方案1】:

    在表 var 中尝试数据类型 numeric(18,2)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-30
      • 1970-01-01
      • 2015-02-10
      • 2011-07-16
      • 1970-01-01
      相关资源
      最近更新 更多