What does ' c.*' mean in this code? Can you explain more obviously,please?

Screen Link:

My Code:

DROP VIEW IF EXISTS chinook.customer_gt_90_dollars;
CREATE VIEW chinook.customer_gt_90_dollars AS 
    FROM chinook.invoice i
    INNER JOIN chinook.customer c ON i.customer_id = c.customer_id
    GROUP BY 1
    HAVING SUM(i.total) > 90;

What I expected to happen:

What actually happened:

Replace this line with the output/error
1 Like

@vadim.donkovtsev7: here you use the alias c for the customer table. when you do SELECT c.*, you are effectively selecting all the columns in the customer table.


Hi @vadim.donkovtsev7: following up with this, is my explanation clear? If so can you mark it as Solution? thanks!

FollowUp question: What does GROUP BY 1 mean here? What column are we grouping exactly, since c.* (which is 1, if m not mistaken) means we are selecting the entire table?

@pranav.kyadar25 you can find out here. Yes c.* refers to the entire table

But if I use GROUP BY c.* instead of GROUP BY 1, I get an error.
So what exactly is 1 here if not c.* ?

It means to group by the first column regardless of what it’s called. You can do the same with ORDER BY.

@pranav.kyadar25 1 refers to the first column as per the answer above. You can only sort by one column at a time, similar to what you can do in excel

1 Like

Thanks I think I get it now.