SQL INTERVIEW QUESTION | Advanced aggregation using ROLLUP

Поділитися
Вставка
  • Опубліковано 8 вер 2024
  • DML Script: datasculptor.b...
    Feedback: forms.gle/NQuC...
    The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insightful and creative purposes.
    The channel covers a wide range of topics related to data manipulation, analysis, visualization, and interpretation. The term "Data Sculptor" emphasizes the creative aspect of working with data, suggesting that it's not just about raw numbers but also about crafting meaningful stories and insights from the information available.
    Viewers can expect a variety of content, including tutorials on popular data analysis tools and programming languages, discussions on emerging trends in the data field, case studies showcasing innovative data applications, and tips for effective data communication. The Data Sculptor aims to demystify complex concepts, making data-related skills accessible to both beginners and experienced professionals.
    Whether you're a student looking to enter the field of data science, a business professional seeking to enhance your analytical skills, or simply someone curious about the world of data, the Data Sculptor UA-cam channel strives to provide engaging and informative content to help you navigate the exciting realm of data exploration and analysis.
    Playlists:
    SQL Interview Questions: • SQL Interview questions
    Recursive CTE: • Recursive CTE
    Power BI and DAX: • Power BI and DAX
    Data Modeling: • Data Modelling
    Generative AIs: • Generative AIs
    Excel: • Excel
    Follow me
    Linkedin: / data-sculptor-93a00b2a8
    Instagram: / datasculptor2895

КОМЕНТАРІ • 3

  • @Manifestion_kannada
    @Manifestion_kannada Місяць тому

    Solve more questions on join and analytical functions

  • @FromPlanetZX
    @FromPlanetZX Місяць тому +1

    Hi, while using UNION ALL method to get the result in required format. I use below method.
    with cte as (
    Select Product, Region, Sales AS TotalSales
    from Sales
    UNION ALL
    Select Product, NULL as Region , SUM(Sales) AS TotalSales
    From Sales
    GROUP BY Product
    UNION ALL
    Select Null as Product, NULL as Region , SUM(Sales) AS TotalSales
    From Sales
    )
    Select * from cte
    Order by (CASE WHEN Product IS NULL THEN 'zz' ELSE Product END),
    (CASE WHEN Region IS NULL THEN 'zz' ELSE Region END);