Valid GROUP BY query doesn't work when combined with INSERT INTO on Oracle

后端 未结 4 1053
旧时难觅i
旧时难觅i 2021-02-13 22:31

I\'m trying to write an INSERT INTO that does a some DISTINCT/GROUP BY work. The query runs perfectly fine as a select statement, but will not work if it\'s wrapped into an INS

4条回答
  •  盖世英雄少女心
    2021-02-13 22:36

    Am I thinking wrong, but is not the sql below equal what you want to achieve?

    INSERT INTO MasterRecords(BatchRecordRecordID, SourceID, BatchID)
    SELECT DISTINCT RecordID, 101, 150
    FROM BatchRecords
    WHERE BatchID = 150
    ;
    

提交回复
热议问题