隨筆-10  評論-10  文章-0  trackbacks-0

          ??? 今天在深入學習了數據庫方面的知識。感覺挺吃力。 今天發現很多理論的知識掌握很不牢固,真是很慚愧,今后還得繼續在理論上下工夫。再說今天接觸的知識吧,今天老總深入講解了關于select查詢方法的使用,發現這個東西實在是太靈活了!目前的自己拿著一個小項目也無法找到下手的方向,這應該就是極度缺乏經驗的表現,今后還得多多練習才能有顯著的提高。關于select,我先是很無語,確實是非常的靈活,就其中的連接一項,就嗆得我要死,看來自己在這幾天還得多多看相關的資料多多做練習才行。希望在研究數據庫的同志們也加油,多看書,多看看好的代碼,多去理解,這樣自己才能有提高。 最后,把今天在老總帶領下完成的關于電子書店數據庫系統的代碼放在這里,對于老手來說非常的簡單,望所有新手共勉!

          (該代碼沒有涉及insert into,其中數據可以根據實際情況添加)

          create table customers
          (customerID int primary key not null,
          customername varchar(20) not null);?

          create table books
          (bookid int primary key not null,
          booktitle varchar(50) not null,
          unitprice int not null
          );?

          create table orders
          (orderid int primary key not null,
          orderdate date default sysdate not null,
          customerid int not null,
          constraint fk_c foreign key (customerid) references customers(customerid)
          );?

          create table orderitems
          (OrderItemID int primary key not null,
          orderid int not null,
          bookid int not null,
          quantity int default '1' not null,
          constraint fk_b foreign key (bookid) references books(bookid), constraint fk_o? foreign key (orderid) references orders(orderid));?

          select c.customername as 客戶名稱, sum(b.unitprice * oi.quantity)
          from customers c
          left join orders o on c.customerid = o.customerid
          left join orderitems oi on o.orderid = oi.orderid
          left join books b on oi.bookid = b.bookid
          where to_char(o.orderdate,'yyyy') = to_char(sysdate,'yyyy')
          group by c.customername

          posted on 2006-11-07 21:50 細雨游風 閱讀(258) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 永和县| 措美县| 青龙| 平罗县| 大冶市| 五指山市| 耒阳市| 射洪县| 云安县| 宕昌县| 册亨县| 平原县| 万载县| 都安| 康定县| 临湘市| 饶阳县| 新龙县| 河东区| 南丹县| 芷江| 樟树市| 忻城县| SHOW| 克什克腾旗| 旅游| 晋州市| 鄂托克前旗| 琼海市| 那曲县| 屏东县| 准格尔旗| 嘉善县| 湖南省| 寻甸| 平武县| 甘孜| 苍梧县| 和龙市| 阿拉善右旗| 山西省|