数据库实践操作(三)

1:

select top 3 with ties GoodsName,GoodsClassName,SaleUnitPrice
   From Table_Goods a join Table_GoodsClass b
      on a.GoodsClsassID = b.GoodsClassID
           order by SalePrice DESC

2:

 select top 3 Goods,COUNT(*) from table_SaleBillDetail
       group by GoodID
          order by COUNT(*) desc

3:

    select GoodsName,SaleUnitPrice, Type = 
       case
            when SaleNameUnitPrice >3000 then '高档商品'
            when SaleNameUnitPriice between 1000 and 3000 then'中档产品'
            when SaleNameUnitPrice <1000 then'低档产品'
      end
      from Table_Goods a join Table_GoodsClass b
         on a.GoodsClassID = b.GoodsClassID
             where GoodsClassName = '家用电器'

4:

select a.GoodsID, 商品销售类别 =
   case 
       where count(b.GoodsID) >10 then'热销商品'
       where count(b.GoodsID) between 5 and 10 then'一般商品'
       where count(b.GoodsID)<5 then'难销产品'
       else'滞销产品'
   end
   from Table_Goods a left join Table_SaleBillDetail b
       on a.GoodsID = b.GoodsID
            group by a.GoodsID

5

select CName, Address, SaleDate, Quantity, UnitPrice
    into 家用电器销售表
    from Table_Customer a join Table_SaleBill b on a.CardID = b.CardID  
    join Table_SaleBillDetail c on c.SaleBillID = b.SaleBillID
    join Table_Goods d on d.GoodsID = c.GoodsID
    join Table_GoodsClass e on e.GoodsClassID = d.GoodsClassID
    where GoodsClassName = '家用电器'

6

select Cname, Address from Table_Customer
    where Address in( 
                                   select Address from Table_Customer where = '王晓'
                                )
    and Cname != '王晓'

7

select GoodsName, SalePrice from Table_Goods a
   where SaleUnitPrice = (select max(SaleUnitPrice) from Table_Goods)

8

select GoodsName, SaleUnitPrice, from Table_Goods a
    join Table_GoodsClass b on a.GoodsClassID = b.GoodsClassID
   where SaleUnitPrice>(
                                         select AVG(SaleUnitPrice) from Table_Goods c
                                             join Table_GoodsClass d on c.GoodsClassID = d.GoodsClassID
                                             where GoodsClassName = '家用电器'                     
                                               )
                                     and GoodsClassName = '家用电器'

9

select distinct CardID from Table_SaleBill
   where exists(   
                          select * from Table_SaleBillDetail
                             where SaleBillID = Table_SaleBill.SaleBillID
                                  and UnitPrice > 2000
                          )

10

select distinct CardID from Table_SaleBill
    where not exists(
                           select * from Table_SaleBillDetail
                               where SailBillID = Table_SaleBillDetail.SaleBillID
                                    and UnitPrice >2000
                           )

11

select distinct CardID from Table_SaleBill
   where SaleBillID not in(   
                                           select SaleBillID from Table_SaleBillDetail
                                           where UnitPrice >2000
                                          )

12

select CustomerID, Cname
    from (
                select * from Table_SaleBill a
                    join Table_SaleBillDetail b
                   on a.SaleBillID = b.SaleBillID
                   where GoodsID = 'G001'
               ) as T1
     join(
               select * from Table_SaleBill a
                   join Table_SaleBillDetail b
                  on a.SaleBillID = b.SaleBillID
                  where GoodsID = 'G002'
              ) as T2
    on T1.CardID = T2.CardID
    join Table_Customer c on c.CardID = T1.CardID

13

select Cno, CName, Semester, Credit,
    SUM(Credit) over(partition by Semester) as'total',
    AVG(Credit) over(partition by Semester)  as'Avg',
    MIN(Credit) over(partition by Semester) as'Min',
    MAX(Credit) over(partition by Semester) as'Max',
from Course

14

select OrderID 订单号, Producer 产品号, OrderQty 订购数量,
     SUM (OrderQty) over (partition by OrderID) as 总计,
     CAST(
                  1.0*OrderQty/SUM(OrderQty) over (partition by OrderID)
                  *100 as DECIMAL(5,2)
                                         ) as 所占百分比

15

select OrderID, ProuductID, OrderQty,
         RANK( ) over
         (partition by OrderID order by OrderQty DESC) as RANK
         from OrderDetail
         order by OrdderID
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
access数据库窗体操作命令代码是用来对数据库窗体进行各种操作的代码。这些代码可以用来增加、编辑、删除和查询数据库的数据,以及对窗体进行各种样式和显示方面的操作。比如,可以使用命令代码来添加新的记录,修改现有记录,删除记录,进行数据筛选和排序,以及设置数据输入的验证规则等操作。 在Access数据库,可以使用VBA(Visual Basic for Applications)编写窗体操作命令代码。通过VBA,可以对数据库窗体进行更加灵活的控制和操作。例如,可以编写代码来实现点击按钮时弹出消息框,或根据用户输入的条件进行数据查询操作。另外,通过VBA还可以对窗体进行样式和布局的调整,使其更加符合用户的需求和审美观。 对于初学者来说,掌握数据库窗体操作命令代码需要一定的学习和实践。可以通过学习VBA编程语言的基础知识,了解Access数据库对象模型的基本结构和操作方法,以及通过实际练习来熟悉和掌握各种命令代码的使用方式和效果。同时,可以借助Access官方文档和在线资源,查阅相关的命令代码和教程,以便更好地理解和掌握窗体操作命令代码的使用技巧。 总之,学习和掌握Access数据库窗体操作命令代码需要不断地实践和积累经验,只有通过不断地练习和总结,才能逐渐掌握这项技能,并能够更加熟练地运用在实际的数据库应用

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值