SQL Technique - Using Function Count() with condition Case in select statement
1.3 هزار بار بازدید -
2 سال پیش
-
Source Code:
1- Create Table
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
2 سال پیش
در تاریخ 1401/02/15 منتشر شده
است.
1,317
بـار بازدید شده