Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

meaning of group by 1,2,3,4

Tags:

group-by

sas

Someone can explain the code below to me? I am confused by Group by 1, 2, 3, 4, because there is no variable and value called 1, 2, 3, 4.

proc sql; create table SampleData as select
uniqID, Category, Grade, Value,

count(uniqID) as CNT,
avg(PRICE) as APR,
avg(Value) as ALE

from DataIn where date ge &intdt. group by 1,2,3,4;
quit;
like image 547
user1481397 Avatar asked Apr 14 '16 15:04

user1481397


People also ask

What is meant by GROUP BY 1?

Example: Group By single column: Group By single column means, to place all the rows with same value of only that particular column in one group.

How do you explain a GROUP BY?

The GROUP BY statement groups rows that have the same values into summary rows, like "find the number of customers in each country". The GROUP BY statement is often used with aggregate functions ( COUNT() , MAX() , MIN() , SUM() , AVG() ) to group the result-set by one or more columns.

What is meant by ORDER BY 1 in SQL?

it means order by the very first column from the select list.

What is GROUP BY clause with example?

The GROUP BY clause is used to get the summary data based on one or more groups. The groups can be formed on one or more columns. For example, the GROUP BY query will be used to count the number of employees in each department, or to get the department wise total salaries.


1 Answers

It's a relative reference to the 1st, 2nd, 3rd, and 4th variables in your select statement. Ie. uniqID, Category, Grade, Value.

like image 188
DanZ Avatar answered Oct 05 '22 13:10

DanZ