on 08-29-2014 1:22 AM
If my table is:
ID
1
2
3
3
5
5
5
I want to create a view with the following result:
ID COUNT
1 1
2 1
3 2
5 3
How would I accomplish this?
How about
CREATE VIEW myview as
SELECT id, count(*) as "COUNT"
FROM mytable
GROUP BY id;
?
- Lars
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure, plenty actually:
Seriously: in case you want a proper answer, you may consider asking in a proper way and present the context and conditions for your requirements.
Nobody here has a crystal ball, so you need to tell us, what you want to know.
- Lars
Well I would say this is a trick question from your tutor
Of course you can setup a view and rely on the default aggregation node.
But this is technically no differnt from the SQL clause usage and basically just hides the aggregation/grouping from the SQL layer.
Actually I am not really sure why one would ask the question like this...
Anyhow, if that is what your tutor wanted, then you got a proper answer.
Another option wouldbe to write a stored procedure with CE functions and table output parameter.
- Lars
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.