得到最終滿足符合品牌名和小分類名的產品標識

2022-02-23 11:58:18 字數 3415 閱讀 5245

--根據小類名稱和品牌名來取客戶資訊

declare @brandname nvarchar(50)

declare @categoryname nvarchar(50) ---分類的中文名

set @categoryname='空調'

set @brandname='海爾'

--取得classid

declare @categoryid nvarchar(15)

if object_id('tempdb.dbo.#categoryids') is not null

begin

print 'exists table tempdb.dbo.#categoryids'

endelse

begin

print 'not exists table tempdb.dbo.#categoryids'

create table #categoryids(

[categoryid] [nvarchar](15) not null

)end

declare categoryidscursor cursor for

select classid from fs_ms_productsclass where classcname=@categoryname

open categoryidscursor

fetch categoryidscursor into @categoryid

while @@fetch_status=0

begin

insert into #categoryids (categoryid) values (@categoryid)

fetch next from categoryidscursor into @categoryid

endclose categoryidscursor

deallocate categoryidscursor

select distinct * from #categoryids

--取得品牌id

declare @brandid char(3)

if object_id('tempdb.dbo.#brandids') is not null

begin

print 'exists table tempdb.dbo.#brandids'

--drop table #categoryids

endelse

begin

print 'not exists table tempdb.dbo.#brandids'

create table #brandids(

[bid] [char](3) not null

)end

declare brandidscursor cursor for

select bid from fs_ms_brand where brandname=@brandname

open brandidscursor

fetch brandidscursor into @brandid

while @@fetch_status=0

begin

insert into #brandids (bid) values (@brandid)

fetch next from brandidscursor into @brandid

endclose brandidscursor

deallocate brandidscursor

select distinct * from #brandids

declare @bid char(3)

declare @classid nvarchar(15)

declare @prdtid char(7)

if object_id('tempdb.dbo.#prdtids') is not null

begin

print 'exists table tempdb.dbo.#prdtids'

endelse

begin

print 'mot exists table tempdb.dbo.#prdtids'

create table #prdtids(

[prdtid] [char](7) not null

)end

declare brandidcursor cursor for

select distinct bid from #brandids

open brandidcursor

fetch brandidcursor into @bid

while @@fetch_status=0

begin

--對這個品牌各個產品小類進行產品篩選開始

declare classidcursor cursor for

select distinct categoryid from #categoryids

open classidcursor

fetch classidcursor into @classid

while @@fetch_status=0

begin

--對小分類進行篩選開始

if cursor_status('global','prdtidinnercusor')>=-1

begin

deallocate prdtidinnercusor

enddeclare prdtidinnercusor cursor for

select prdtid from fs_ms_products where classid=@classid and brandname=@bid

open prdtidinnercusor

fetch prdtidinnercusor into @prdtid

while @@fetch_status=0

begin

insert into #prdtids (prdtid) values (@prdtid)

fetch next from prdtidinnercusor into @prdtid

endclose prdtidinnercusor

deallocate prdtidinnercusor

--結束

fetch next from classidcursor into @classid

endclose classidcursor

deallocate classidcursor

--篩選結束

fetch next from brandidcursor into @bid

endclose brandidcursor

deallocate brandidcursor

select distinct prdtid from #prdtids

用Python滿足滿足自己的「小虛榮」

首先宣告,學習這個只是為了好玩,只是為了好玩,並不是想用這個弄虛作假,做一些不好的事情!一心想做技術人,自製自治!我們有時候發布一篇日誌,或者是一篇博文,總希望自己的瀏覽量能高點,這樣看起來也倍有面子。那麼我們可以選擇把博文或日誌的內容弄的更精,這樣就會有更多的人過來看。或者我們宣傳一下,讓大家來看...

最終排名 sdut oj

time limit 1000ms memory limit 65536kb 第四屆山東理工大學acm網路程式設計擂台賽比賽完後需要產生乙個最終排名,排名按照題數多少來決定。但是有太多的隊伍參與,手動計算排名已經不能滿足比賽的需求。現在有乙份名單記錄各個隊伍的id和做出的題目數,需要你寫乙個程式,產...

2446 最終排名

problem description 第四屆山東理工大學acm網路程式設計擂台賽比賽完後需要產生乙個最終排名,排名按照題數多少來決定。但是有太多的隊伍參與,手動計算排名已經不能滿足比賽的需求。現在有乙份名單記錄各個隊伍的id和做出的題目數,需要你寫乙個程式,產生最終的排名。為了簡化題目,這裡的排名...