{"action":"created","issue":{"url":"https://api.github.com/repos/querydsl/querydsl/issues/1780","repository_url":"https://api.github.com/repos/querydsl/querydsl","labels_url":"https://api.github.com/repos/querydsl/querydsl/issues/1780/labels{/name}","comments_url":"https://api.github.com/repos/querydsl/querydsl/issues/1780/comments","events_url":"https://api.github.com/repos/querydsl/querydsl/issues/1780/events","html_url":"https://github.com/querydsl/querydsl/issues/1780","id":130492207,"number":1780,"title":"Oracle WITH Clause","user":{"login":"natros","id":4996289,"avatar_url":"https://avatars.githubusercontent.com/u/4996289?v=3","gravatar_id":"","url":"https://api.github.com/users/natros","html_url":"https://github.com/natros","followers_url":"https://api.github.com/users/natros/followers","following_url":"https://api.github.com/users/natros/following{/other_user}","gists_url":"https://api.github.com/users/natros/gists{/gist_id}","starred_url":"https://api.github.com/users/natros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natros/subscriptions","organizations_url":"https://api.github.com/users/natros/orgs","repos_url":"https://api.github.com/users/natros/repos","events_url":"https://api.github.com/users/natros/events{/privacy}","received_events_url":"https://api.github.com/users/natros/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/querydsl/querydsl/milestones/41","html_url":"https://github.com/querydsl/querydsl/milestones/4.0.9","labels_url":"https://api.github.com/repos/querydsl/querydsl/milestones/41/labels","id":1554200,"number":41,"title":"4.0.9","description":"","creator":{"login":"timowest","id":574167,"avatar_url":"https://avatars.githubusercontent.com/u/574167?v=3","gravatar_id":"","url":"https://api.github.com/users/timowest","html_url":"https://github.com/timowest","followers_url":"https://api.github.com/users/timowest/followers","following_url":"https://api.github.com/users/timowest/following{/other_user}","gists_url":"https://api.github.com/users/timowest/gists{/gist_id}","starred_url":"https://api.github.com/users/timowest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timowest/subscriptions","organizations_url":"https://api.github.com/users/timowest/orgs","repos_url":"https://api.github.com/users/timowest/repos","events_url":"https://api.github.com/users/timowest/events{/privacy}","received_events_url":"https://api.github.com/users/timowest/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":1,"state":"open","created_at":"2016-01-31T21:11:48Z","updated_at":"2016-02-09T13:16:10Z","due_on":"2016-02-28T22:00:00Z","closed_at":null},"comments":1,"created_at":"2016-02-01T21:38:57Z","updated_at":"2016-02-11T15:46:36Z","closed_at":"2016-02-09T13:15:33Z","body":"I'm trying to implemente this query with querydsl-sql 4.0.8\r\n\r\n```sql\r\nWITH last_rfid AS (\r\n        SELECT\r\n            r.login,\r\n            max(r.updated) updated\r\n        FROM rfid r\r\n        GROUP BY r.login)\r\nSELECT *\r\nFROM rfid r\r\n    JOIN last_rfid l\r\n        ON l.login = r.login\r\n            AND l.updated = r.updated\r\n```\r\n\r\nwith this code\r\n\r\n```java\r\nQRfid rfid = QRfid.rfid1;\r\nQRfid lastRfid = new QRfid(\"last_rfid\");\r\nList<Rfid> list = queryFactory.query()\r\n        .with(lastRfid,\r\n                select(lastRfid.login, lastRfid.updated.max().as(\"updated\"))\r\n                        .from(lastRfid)\r\n                        .groupBy(lastRfid.login))\r\n        .select(rfid)\r\n        .from(rfid)\r\n        .join(lastRfid).on(rfid.login.eq(lastRfid.login), rfid.updated.eq(lastRfid.updated))\r\n        .fetch();\r\n```\r\n\r\nand I'm getting\r\n\r\n```\r\n1\tfsousa\t2016-02-02 19:40:20\r\n2\tfsousa\t2016-02-01 09:43:40\r\n\r\n```\r\ninstead of\r\n```\r\n1\tfsousa\t2016-02-02 19:40:20\r\n```\r\n\r\nI created a small project that reproduces the problem with HSQLDB\r\nhttps://github.com/natros/querydsl-with\r\n\r\nIn the output you can see that the RFID table is joining with the same table\r\n\r\n```sql\r\n21:26:15.289 [main] DEBUG com.querydsl.sql.AbstractSQLQuery - with last_rfid as (\r\nselect last_rfid.LOGIN, max(last_rfid.UPDATED) as updated \r\nfrom RFID last_rfid group by last_rfid.LOGIN) \r\nselect RFID.LOGIN, RFID.RFID, RFID.UPDATED from RFID RFID \r\njoin RFID last_rfid \r\n   on RFID.LOGIN = last_rfid.LOGIN \r\n   and RFID.UPDATED = last_rfid.UPDATED\r\n0 | fsousa | 01-02-2016 0:00\r\n1 | fsousa | 12-01-2016 0:00\r\n2 | fsousa | 01-01-2016 0:00\r\n```"},"comment":{"url":"https://api.github.com/repos/querydsl/querydsl/issues/comments/182924176","html_url":"https://github.com/querydsl/querydsl/issues/1780#issuecomment-182924176","issue_url":"https://api.github.com/repos/querydsl/querydsl/issues/1780","id":182924176,"user":{"login":"natros","id":4996289,"avatar_url":"https://avatars.githubusercontent.com/u/4996289?v=3","gravatar_id":"","url":"https://api.github.com/users/natros","html_url":"https://github.com/natros","followers_url":"https://api.github.com/users/natros/followers","following_url":"https://api.github.com/users/natros/following{/other_user}","gists_url":"https://api.github.com/users/natros/gists{/gist_id}","starred_url":"https://api.github.com/users/natros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natros/subscriptions","organizations_url":"https://api.github.com/users/natros/orgs","repos_url":"https://api.github.com/users/natros/repos","events_url":"https://api.github.com/users/natros/events{/privacy}","received_events_url":"https://api.github.com/users/natros/received_events","type":"User","site_admin":false},"created_at":"2016-02-11T15:46:36Z","updated_at":"2016-02-11T15:46:36Z","body":"I tested the latest version and it seems that it is working as expected.\r\n\r\nThank you."}}