Secrets of Group By Clause in SQL Server

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024

Комментарии • 2

  • @PradeepVerma-tg9ke
    @PradeepVerma-tg9ke Год назад

    Create Table Incremental_Loading
    (
    CID Int Primary Key,
    CourseName Varchar(40) NOT NULL ,
    Category Char(1) NULL, Check (Category = 'B' or Category = 'M' or Category = 'A' ) ,
    Fee Smallmoney NOT NULL Check (Fee >=0)
    )
    INSERT INTO Incremental_Loading VALUES (10,'Python','B',1000)
    INSERT INTO Incremental_Loading VALUES (20,'Java','M',2000)
    INSERT INTO Incremental_Loading VALUES (30,'Software Development','A',3000)
    INSERT INTO Incremental_Loading VALUES (40,'Web Development','B',4000)
    INSERT INTO Incremental_Loading VALUES (50,'Database Engineering','M',5000)
    INSERT INTO Incremental_Loading VALUES (60,'Linux','A',6000)
    INSERT INTO Incremental_Loading VALUES (70,'C++','B',7000)
    INSERT INTO Incremental_Loading VALUES (80,'Scrum','M',8000)
    INSERT INTO Incremental_Loading VALUES (90,'HTML','A',9000)
    INSERT INTO Incremental_Loading VALUES (100,'Jenkins','B',10000)
    INSERT INTO Incremental_Loading VALUES (110,'sql','M',11000)
    INSERT INTO Incremental_Loading VALUES (120,'TSQL','A',12000)
    INSERT INTO Incremental_Loading VALUES (130,'msbi','B',13000)
    INSERT INTO Incremental_Loading VALUES (140,'power BI','M',14000)
    INSERT INTO Incremental_Loading VALUES (150,'tablue','A',15000)
    INSERT INTO Incremental_Loading VALUES (160,'AWS','M',16000)
    INSERT INTO Incremental_Loading VALUES (170,'Snowflake','B',17000)
    INSERT INTO Incremental_Loading VALUES (180,'datawareHouse','M',18000)
    INSERT INTO Incremental_Loading VALUES (190,'Logic Circuits ','A',19000)
    INSERT INTO Incremental_Loading VALUES (200,'Computer Programing ','B',20000)
    INSERT INTO Incremental_Loading VALUES (210,'Engineering Mechanics','M',21000)
    INSERT INTO Incremental_Loading VALUES (220,'Applied Chemistry','A',22000)
    select Category ,sum(fee) as Total_Fee
    from Incremental_Loading
    Group by Category
    getting correct output but i want to see CID data as well with this data not not getting sucess @Bhaskar Jogi (Go Online Trainings)

    • @ianwanjala8621
      @ianwanjala8621 Год назад

      impossible since cid is a primary key thus cannot be repeated for the grouped data. For example, what cid would you give to P?