shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-12-19 : 16:15:11
|
Query need be displaying Product , last SubProduct in the list based on IsPrimaryDisplay quantity for each Product values multiplied. I need to have an query for below resultCREATE TABLE [dbo].[Product_Table]([Product Id] [char](10) NULL,[IsPrimary] [int] NULL,[Quantity] [numeric](18, 0) NULL) ON [PRIMARY]INSERT INTO Product_Table ([Product Id], IsPrimary, Quantity) VALUES ('P001', 1, 0)INSERT INTO Product_Table ([Product Id], IsPrimary, Quantity) VALUES ('P001.1', 0, 2)INSERT INTO Product_Table ([Product Id], IsPrimary, Quantity) VALUES ('P001.2', 0, 4)INSERT INTO Product_Table ([Product Id], IsPrimary, Quantity) VALUES ('P001.3', 0, 5)INSERT INTO Product_Table ([Product Id], IsPrimary, Quantity) VALUES ('P002', 1, 0)INSERT INTO Product_Table ([Product Id], IsPrimary, Quantity) VALUES ('P002.1', 0,6)INSERT INTO Product_Table ([Product Id], IsPrimary, Quantity) VALUES ('P002.2', 0,7)INSERT INTO Product_Table ([Product Id], IsPrimary, Quantity) VALUES ('P002.3', 0,9)INSERT INTO Product_Table ([Product Id], IsPrimary, Quantity) VALUES ('P002.4', 0,10)INSERT INTO Product_Table ([Product Id], IsPrimary, Quantity) VALUES ('P002.5', 0,11)Need the result to be asProduct Id | SubProduct |QuantityP001 | | 40P001 | P001.3 |0P002 | | 41580P002 | P002.5| 0THANKSSHANMUGARAJnshanmugaraj@gmail.com |
|