partition by

Vineet S 1,230 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
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,060 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,661 questions
{count} votes

Accepted answer
  1. LiHongMSFT-4306 28,576 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".

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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