crishna1
asked on
group by
select to_date('2004/02/11 07:32:00', 'YYYY/MM/DD HH24:MI:SS'),count (*) from XXX group by XXX;
How can i reference the group by on a date column? Please help!
How can i reference the group by on a date column? Please help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> what DB engine are you using?
This is a good question, as different databases use different flavours of SQL...
This is a good question, as different databases use different flavours of SQL...
Is a good question, because of internal functions or anything. If you are using PL/SQL or T-SQL the functions changes. For example in MS T-SQL there are several options that in Sybase T-SQL doesn't work.
Besides the question doesn't have to be a "good" one... is only a question. In generarlly speaking the questions are only for answer them, not judging them.
Besides the question doesn't have to be a "good" one... is only a question. In generarlly speaking the questions are only for answer them, not judging them.
Venabili,
I object... because I tried the TimYates solution in Sybase and doesn't seem to work.
The mine works in Sybase(T-SQL).
-tom
I object... because I tried the TimYates solution in Sybase and doesn't seem to work.
The mine works in Sybase(T-SQL).
-tom
Mine will work in Oracle and Postgres (I think)
It's a split then...
Tim in PL/SQL, mine T-SQL
-tom
Tim in PL/SQL, mine T-SQL
-tom
Doesn't sybase have the "AS" keyword then?
Yes it has...
But you can not referer to an AS field in a group by clause. You have to be explicit.
-tom
But you can not referer to an AS field in a group by clause. You have to be explicit.
-tom
Fair enough :-)
A split between me and you seems more than fair then :-)
Tim
A split between me and you seems more than fair then :-)
Tim
by the way, this question does not make sense.
What is the author trying to do anyway ?? - group-by column has to be referenced in the 'select' part!
According to the ANSI, there are 2 syntaxes for group-by clause:
1) use full column name : group by col_name
2) use relative number of the column in select clause: group by 1
What is the author trying to do anyway ?? - group-by column has to be referenced in the 'select' part!
According to the ANSI, there are 2 syntaxes for group-by clause:
1) use full column name : group by col_name
2) use relative number of the column in select clause: group by 1
The question is about how to do a Group By clause, and the answers are right for T-SQL and PL/SQL
-tom
-tom
An examle:
SELECT YEAR(Date_Column),SUM(Sum_