Ok I am providing you with sample data
Category Id CategoryName
1 Gifts
2 Sports
3 Caskets
4 Cards
Product Id CategoryId ProductName
3 1 Bag
4 1 Camera 3D
5 1 MousePad
10 1 LampShade
11 1 NamePlate
12 1 Box
6 2 Apron
7 2 Baby
8 2 Cup
103 3 Casket Spray with Fabric Drape
104 3 Full Cover Hanging Casket Spray
105 3 Green Casket Spray with Apple
106 3 Infant Casket Spray with Daisies
107 3 Interior Casket Lid Arrangement
The user will input 3,2(ie, 3 categories with 2 products each), the output should be
3 1 Bag
4 1 Camera 3D
6 2 Apron
7 2 Baby
103 3 Casket Spray with Fabric Drape
104 3 Full Cover Hanging Casket Spray
If he gives 2,4(ie. 2 categories with 3 products each) the output should be as follows, it should not take the category number 2 as it has only 2 products
3 1 Bag
4 1 Camera 3D
5 1 MousePad
10 1 LampShade
103 3 Casket Spray with Fabric Drape
104 3 Full Cover Hanging Casket Spray
105 3 Green Casket Spray with Apple
106 3 Infant Casket Spray with Daisies
I tried this way, now only one restriction, I want to pass the value "3", in "select distinct top 3" as a parameter, thro stored procedure,
select * from es_product where es_product.categoryid in
(select distinct top 3 id from es_category)order by es_product.categoryid
in the stored procedure when I write
declare @count as int
set @count=3
select * from es_product where es_product.categoryid in
(select distinct top @count id from es_category)order by es_product.categoryid
it does not accept
what the variable count
What should I do?
Regards
cmrhema