Grouping with PIVOT?

  • Good morning SSC,

    I have the following query that returns the data needed but too much data. I want the data to return like:

    2XTHC 25CW17872-SC63882 2

    KCR 07CW16412-ST65054 4

    KCR 11CW16414-ST68022 1

    68566 67

    LCZ 2500CW16793-ST66342 3

    66692 8

    LCR 25CW16405-S67088 14

    MCT 4000CW16967-PVC66440 6

    XTL 35CW16440-S68718 18

    123

    SELECT A.MODEL, A.ITEM, C.WORKORDER, COUNT(C.EPC) DUF

    FROM COMPLETEDUNIT C

    JOIN ASSIGNWORKORDER A

    ON C.WORKORDER = A.WORKORDER

    JOIN TAGSREAD T

    ON C.EPC = T.EPC

    GROUP BY A.MODEL, A.ITEM, C.WORKORDER WITH ROLLUP

    ORDER BY GROUPING(A.ITEM)

  • Quick question, can you post DDL (create table) for the tables, some consumable sample data as an insert statements and the expected output? This will make answering your question a lot easier.

    😎

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply