Menu

📰
0

Primary key, grain of the table and group by

Reddit r/SQL·u/WiseWeird6306·about 1 month ago
#toCPeTy1
#primary#group#cols#grain#article#discussion
Reading 0:00
15s threshold

Primary key, grain of the table and group by Can someone explain me how to understand the difference between them? What I know- 1. Primary key is a column or set of columns that uniquely identifies each row. It may or may not have a business meaning 2. Grain of the table - one row or line item describing what it is, like one row per daily customer session 3. Group by- we use this to get one line item per item of that group. For example something grouped by business type and country, will get me data for unique combination of business type and country Now I need clarification here- A primary key should ALWAYS be in a group by statement in SQL or not, if it is needed in the output - True? A column in group by is not necessary a primary key -True?…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More