隨筆-10  評(píng)論-10  文章-0  trackbacks-0

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

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

          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 細(xì)雨游風(fēng) 閱讀(262) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 尼木县| 南城县| 兴和县| 麟游县| 平陆县| 东方市| 泉州市| 大化| 开平市| 阿尔山市| 海阳市| 尼玛县| 祥云县| 河北区| 鄂伦春自治旗| 长泰县| 增城市| 德保县| 南雄市| 额济纳旗| 北京市| 林甸县| 潞城市| 彭山县| 临湘市| 额济纳旗| 西安市| 永泰县| 白银市| 渝中区| 外汇| 巢湖市| 兴城市| 雅江县| 康保县| 湖州市| 富民县| 周至县| 平凉市| 洛川县| 久治县|