2013年6月5日

先定義子查詢

WITH XX AS (子查詢)

然後就可以對XX處理



with a as
  (
  select * from member,
  (
  SELECT name,org_id,COUNT(*)
  FROM member
  GROUP BY name,org_id
  HAVING COUNT(*) > 1
  )t
  where member.name=t.name
  and member.org_id=t.org_id
  )

select id from a
WHERE a.id!=(select max(id)from a)

沒有留言:

張貼留言