filmov
tv
SQL Technique - Using Function Count() with condition Case in select statement
![preview_player](https://i.ytimg.com/vi/1NknN-MTtl8/maxresdefault.jpg)
Показать описание
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
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
SQL Window Functions in 10 Minutes
SQL Window Function | How to write SQL Query using RANK, DENSE RANK, LEAD/LAG | SQL Queries Tutorial
Data Analysis SQL Interview Questions | Running SUM | Who Hit the Sales Target First
SQL indexing best practices | How to make your database FASTER!
Secret To Optimizing SQL Queries - Understand The SQL Execution Order
Follow this SQL RoadMap to kick start your SQL journey | #learncoding
CAST Function (SQL) - Converting Data Types
FUNCTIONS IN PL SQL WITH EXAMPLES | PL/SQL TUTORIAL
A first look at DuckDB Functions and new features in version 1.10
🔍SQL SUBSTR Function Trick (Negative SUBSTR!) | SQL Interview Challenge
SQL Server Queries Part 7 - Using Functions in Queries
Advanced SQL Tutorial | CTE (Common Table Expression)
SQL | RANK Vs DENSE_RANK #sqltips #sqlserver
Learn how to write SQL Queries(Practice Complex SQL Queries)
Intermediate SQL Tutorial | Partition By
SQL WITH Clause | How to write SQL Queries using WITH Clause | SQL CTE (Common Table Expression)
SQL Tutorial 6: MySQL Built-in Functions in SQL
79 What are user defined functions in sql server
Advanced SQL Tutorial | Subqueries
SQL Window Functions: Explained (with examples)
Top 10 SQL Interview Queries | Popular SQL Queries for SQL Interview
Advanced Aggregate Functions in SQL (GROUP BY, HAVING vs. WHERE)
SQL Tutorial: CASE WHEN with aggregate functions
SQL Interview Question: Find the Last Record in a Table (SOLVED!)
Комментарии