Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Get ProductConfig With Lowest Prise

$
0
0
Hi I Have 3 Tables Please Help me to Get This Result :ProductId - ProductConfigId (With Min Price) -MinPrice - HasGift1 > 3 > 70 > 12 > 4 > 700 > 13 > 7 > 820 > 0 5 > 9 > 55 > 1------------------------------------------------------CREATE TABLE [dbo].[TBL_Product]( [ID] [int] IDENTITY(1,1) NOT NULL, [ProductName] [varchar](100) NULL) ON [PRIMARY]GOCREATE TABLE [dbo].[TBL_ProductConfig]( [Id] [int] IDENTITY(1,1) NOT NULL, [ProductId] [int] NULL, [Config] [varchar](100) NULL, [HasGift] [bit] NULL) ON [PRIMARY]GOCREATE TABLE [dbo].[TBL_Price]( [id] [int] IDENTITY(1,1) NOT NULL, [ProductConfigID] [int] NULL, [Amount] [int] NULL) ON [PRIMARY]GOInsert into TBL_Product values('P1')Insert into TBL_Product values('P2')Insert into TBL_Product values('P3')Insert into TBL_Product values('P4')Insert into TBL_Product values('P5')Insert into TBL_ProductConfig Values (1,'C11',0)Insert into TBL_ProductConfig Values (1,'C12',1)Insert into TBL_ProductConfig Values (1,'C13',1)Insert into TBL_ProductConfig Values (2,'C21',1)Insert into TBL_ProductConfig Values (3,'C31',1)Insert into TBL_ProductConfig Values (3,'C32',1)Insert into TBL_ProductConfig Values (3,'C33',0)Insert into TBL_ProductConfig Values (3,'C34',0)Insert into TBL_ProductConfig Values (5,'C51',1)Insert into TBL_ProductConfig Values (5,'C51',0)Insert Into Tbl_Price Values(1,100)Insert Into Tbl_Price Values(2,150)Insert Into Tbl_Price Values(3,70)Insert Into Tbl_Price Values(4,700)Insert Into Tbl_Price Values(5,900)Insert Into Tbl_Price Values(6,920)Insert Into Tbl_Price Values(7,820)Insert Into Tbl_Price Values(8,820)Insert Into Tbl_Price Values(9,55)Insert Into Tbl_Price Values(9,75)

Viewing all articles
Browse latest Browse all 3145

Trending Articles