Hi,
I'm trying do make a script that puts all columns that need to be in the group by clause automatically.
This is because, I have a rather large program that works with MySQL. Now I want to make it work with MS SQL. The problem is that the SQL Statements aren't compatible.
So I'm making a script that will take a MySQL compatible SQL Statement and convert it to a MSSQL compatible SQL Statement.
But now I'm stuck, MSSQL doesn't like queries like:
SELECT field1, field2, field3, sum( field4 )
FROM mytable
GROUP BY field1
It will give an error because field1, field2 and field3 are not in the group by clause. This works with MySQL!
So, how can I take the previous query, and in some way append to the group by clause the fields that need to be in the group by????
Check this other example:
SELECT *
FROM mytable
GROUP BY field1
It seems rather complicated to me.... maybe some of you can think of a solution. Quite a challenge isn't it?? 🙂
Thanks!