Forum Replies Created

Viewing post 1 (of 1 total)

  • RE: How to group the total count of similar items?

    create table tab(

    ItemId int,

    ParentId int,

    Name varchar(10),

    QtyAvailable int);

    insert into tab (

    ItemId,

    ParentId,

    Name,

    QtyAvailable)

    select

    1 as ItemId,

    null as ParentId,

    'Package A' as Name,

    10 as QtyAvailable

    union all

    select

    2,

    1,

    'Item 1',

    2

    union all

    select

    3,

    1,

    'Item 2',

    3;

    with

    subquery_cte as (

    select

    coalesce(ParentId, ItemId) as Id,

    case

    when

    ParentId is null

    then

    Name

    else

    null

    end...

Viewing post 1 (of 1 total)