GROUP BY SUBSTR ON DB2

| Comment | No TrackBacks

On DB2, group by substr(XXXX,1,3) is not accepted. So, by the way.

SELECT b.SUB, COUNT(*)
FROM TABLEA a JOIN
(SELECT DISTINCT SUBSTR(ID,1,1) AS SUB
FROM TABLEA) b ON SUBSTR(a.ID,1,1) = b.SUB
GROUP BY b.SUB

No TrackBacks

TrackBack URL: http://server.everfine.com.tw/blog/mt-tb.cgi/230

February 2012

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      

Archives

Powered by Movable Type 4.34-en

About this Entry

This page contains a single entry by philipz published on January 23, 2009 11:37 AM.

DB2 Error Messages (SQLCODE, SQLSTATE) Part2 was the previous entry in this blog.

登上雜誌封面 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.