有单价(price)、数量(amount)、总价(total)
sql语句怎么写?

解决方案 »

  1.   

    select price, amount, price * amount total from table;
      

  2.   

    其中price在产品表中,而另两个在订货表中,这样子怎么写呢?
      

  3.   

    select a.amount,b.price,a.amount*b.price a.total from productinfo b,orderinfo a
    这样写报错,为什么呢?
      

  4.   

    表结构发下吧,没有where条件联系两个表当然要报错了
      

  5.   

    a.amount*b.price a.total 多写了a.
    应该是a.amount*b.price total 
      

  6.   

    别名里是不能有a.的,而且没有where条件那要查处多少数据啊
      

  7.   

    产品表的结构
    pid
    cid
    pname
    amount
    price
    订货表的结构
    字段名
    oid
    pid
    amount
    total
    orderdate
      

  8.   

    select a.amount
         , b.price
         , a.amount*b.price total 
    from   productinfo b,orderinfo a 
    where  a.pid   = b.pid