10.
select a.order_no,
  b.cus_name,c.emp_name,a.tot_amt,
  a.order_date,a.ship_date,
  a.invoice_no,a.o_static from
sales a,customer b,employee_hope c
where a.cus_id=b.cus_id(+)
  and a.sale_id=c.emp_no(+)
  and a.order_date>=date'1996-10-1' 
  and a.order_date<date'1996-11-1';select a.order_no,
  (select cus_name from customer where cus_id=a.cus_id)cus_name,
  (select emp_name from employee_hope where emp_no=a.sale_id)emp_name,
  a.tot_amt,a.order_date,a.ship_date,a.invoice_no,a.o_static
from sales a
where a.order_date>=date'1996-10-1' 
  and a.order_date<date'1996-11-1';
11.
select addr,count(1)
from customer a
group by addr;
12.
select b.addr,sum(a.tot_amt)
from sales a,customer b
where a.cus_id=b.cus_id
group by b.addr;
13.
select a.emp_name,a.title,
  trunc(months_between(sysdate,birthday)/12) age
from employee_hope a
where a.title<>'职员'
order by birthday desc;
14.
select distinct a.order_no,b.sup_name
from sale_item a,supply b
where a.sup_id=b.sup_id
  and a.unit_price>2000
  and a.order_date>=date'1996-8-1';
40.
select b.sup_name,sum(a.qty*a.unit_price)
from sale_item a,supply b
where a.sup_id=b.sup_id
group by b.sup_id,b.sup_name都很简单啊,这些题不错
楼主自己练习一下比较好
不会的再问吧

解决方案 »

  1.   

    a.order_date>=date'1996-10-1' 这是什么语法
    相当于to_date()函数吗
    wildwave 麻烦稍加解释下
      

  2.   

    to_date的简化写法,只对yyyy-mm-dd格式字符串能用
      

  3.   

    a.order_date>=date'1996-10-1' 这是什么语法
    相当于to_date()函数吗
    wildwave 麻烦稍加解释下
      

  4.   

    要转换一下
    a.order_date>=to_date('1996-10-01','YYYY-MM-DD') 
      

  5.   

    你自己应该先写,然后把不会的拿出来问,这样才有提高。两天时间,这些sql应该写出来了。培训要交?真不知道如果不会的话,你光把答案交上去有什么意义呢?人家老师不缺答案,你给他他还以为你都会了,最终吃亏的还是你自己
      

  6.   

    大哥,我才学oracle不到一周的时间啊,我有些语法还不是清楚啊啊,想通过这个来提高自己一些啊,不过让我自己来写,我昨天一天就写了4,5个简单的,,,要是都让我自己来写,我肯定在2天的时间完成不了,,,好心的帮帮我啊,我不是对付老师,是为了我自己好啊,
    先谢谢了!@@
      

  7.   

    17.
      看看对不对。
       
    select t,sum(m) from
         (
         select  to_char(order_date,'yyyy-mm') t,sum(qty*unit_price) m 
         from sale_item group by order_date
         ) group by t
      

  8.   

    很多语句其实都是自己真正在用,用多了之后才熟悉的。
    起先可以网上查资料等等
    还有一些很变态的sql语句,其实开发中用到的并不是太多。
      

  9.   

    select to_char(a.order_date,'yyyy-mm')year_month,sum(a.tot_amt)
    from sales a
    group by to_char(a.order_date,'yyyy-mm');这个可能根据sale_item来统计也行,不过通过订单统计应该比较好