Source Code:
1- Create Table
CREATE TABLE [dbo].[SaleInvoice](
[InvoiceNo] [varchar](50) NULL,
[Dates] [datetime] NULL,
[ItemCode] [varchar](50) NULL,
[Qty] [int] NULL,
[Price] [numeric](18, 2) NULL,
[Amount] AS ([Qty]*[Price]),
[Promotion] [varchar](50) NULL
) ON [PRIMARY]
GO
2- Insert Data into Table by yourself
3- Write this script
select ItemCode,Count(case when Promotion='Yes' then 1 end) as num_promotion from SaleInvoice
group by ItemCode