zoukankan      html  css  js  c++  java
  • DaishaPocedureOfMine(代码)

    create procedure GetGoodsInfoByPageNumber
    (
        @provideID int,
        @pageNumber int,
        @GoodsCountOfOnePage float,
        @howManyGoods int output,
        @howManyPage int output
        
    )
    as
    declare @Goods table
    (
        RowNumber int,
        GoodsId int,
        GoodsName varchar(50),
        GoodsDescribe varchar(200),
        PhotoName varchar(200),
        SkuId int,
        Price money,
        MarketPrice money,
        SkuStirng varchar(200)
    )
    insert into @Goods
    select ROW_NUMBER() over (order by Goods.GoodsId),
    GoodsId,GoodsName,GoodsDescribe,PhotoName,SkuId,Price,MarketPrice,SkuStirng from Goods,Photos,Sku where Goods.GoodsId in (select GoodsId from Goods where Goods.ProvideCateId = @provideID) and Photos.ProvideGoodsId = Goods.GoodsId and Photos.FatherPhotoId is null and Photos.PhotoIdentity = 1 and Sku.ProvideGoodsId = Goods.GoodsId and Sku.SkuIdentity = 1
    ----给输出参数赋值
    select @howManyGoods = COUNT(GoodsId) from @Goods
    select @howManyPage = Ceiling(@howManyGoods / @GoodsCountOfOnePage)
    
    select GoodsId,GoodsName,GoodsDescribe,PhotoName,SkuId,Price,MarketPrice,SkuStirng from @Goods
    where RowNumber > (@pageNumber - 1) * @GoodsCountOfOnePage
    and RowNumber <= @pageNumber * @GoodsCountOfOnePage
    go
    
    use Daisha
    declare @howManyGoods int
    declare @howManyPage int
    exec GetGoodsInfoByPageNumber 10,4,5,@howManyGoods out,@howManyPage out
    select @howManyGoods as 商品总数
    select @howManyPage as 共几页
    
    -----select * from Goods where GoodsId = 177
    -----select * from Photos where Photos.ProvideGoodsId = 177
  • 相关阅读:
    Leetcode 剑指 Offer 27(二叉树的镜像)
    Leetcode 1022从根到叶的二进制之和
    Leetcode 993二叉树的堂兄弟节点
    Leetcode 965单值二叉树
    Leetcode 938 二叉搜索树的范围和
    hdu 2082 找单词
    母函数模板
    hdu 1398 Square Coins
    hdu 1085 Holding Bin-Laden Captive!
    hdu 1028 Ignatius and the Princess III
  • 原文地址:https://www.cnblogs.com/fllowerqq/p/8970598.html
Copyright © 2011-2022 走看看