Log in

View Full Version : Limits of GROUP BY??



nikomou
01-02-2009, 12:25 AM
Hello,

I have 3 tables in a database, the first being a list of handsets, the second a list of tariffs and the third a list of the deals..

handsets table
handsetid|handsetname|handsetmake

tariff table
tariffid|tariffname

deals table
dealsid|dealsinfo|tariffid|handsetid

I am planning on using Join Left to join the tables together which I shouldnt have any problems doing..

My problem here is that I want to use GROUP BY on the first 2 characters of the tariffid field..

an example of the tarrifid
o2xxx, o2yyy, o2zzz, tmxxx, tmyyyy

Would this be at all possible?

Twey
01-02-2009, 12:37 AM
Certainly: ... GROUP BY SUBSTRING(tariffid, 0, 2)

nikomou
01-02-2009, 01:02 AM
twey, once again.. thank you VERY VERY much!

You have saved me hours of work here!