Share via

partition by

Vineet S 1,390 Reputation points
2024-11-20T20:43:21.9033333+00:00

Hi,

how to add partition by in below table where there is no date key or duration..please give example

here is example of sample data

customerid - 1

product - grains

productcategory-rice

sales- 1000

Azure SQL Database
Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories


Answer accepted by question author

  1. LiHongMSFT-4306 31,621 Reputation points
    2024-11-21T02:06:57.86+00:00

    Hi @Vineet S

    how to add partition by in below table where there is no date key or duration..please give example

    If you mean using PARTITION BY in Windows Functions, then the key is to choose a column (or columns group) that makes sense for dividing your data into groups. You don’t need a date or duration column to partition the data. For example, you can partition by product or productcategory.

    If you mean creating partitioned table where there is no date key or duration, you can still partition by other columns that makes sense for your data.

    For example, you could partition by different product types, like foods, clothes, appliances...

    Or partition by the range of sales, like 0~500 belongs to partition1, 501~1000 belongs to partition2...

    For more details, review this doc: Create partitioned tables and indexes.

    Also, see these two articles for more examples: Database table partitioning in SQL Server; SQL Server Table Partitioning.

    Best regards,

    Cosmog


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Was this answer helpful?

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.