1. Список говнокодов пользователя dmezentsev

    Всего: 1

  2. SQL / Говнокод #8364

    −118

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    DROP PROCEDURE IF EXISTS postgkh.ACCOUNT_ITM $$
    CREATE PROCEDURE postgkh.ACCOUNT_ITM(IN PERIOD DATE, IN ACC_ID INT)
    BEGIN
        SELECT A.ACCOUNT_ID, A.ACCOUNT_NO
    # Смачный кусок кода
          (SELECT GROUP_CONCAT(document_no ORDER BY document_no SEPARATOR ', ') DOCUMENT_NO
                FROM
                     (SELECT d.document_no document_no
                        FROM postgkh.docar dr INNER JOIN
                             postgkh.document d ON dr.document_id = d.document_id
                        WHERE dr.account_id = ACC_ID
                              AND d.document_fromdate <= LAST_DAY(PERIOD)
                              AND (d.DOCUMENT_CLOSEDATE >= PERIOD OR d.DOCUMENT_CLOSEDATE IS NULL)
                      ) d
             ) DOCUMENT_NO
        FROM postgkh.ACCOUNT
        WHERE A.ACCOUNT_ID = ACC_ID
        GROUP BY A.ACCOUNT_ID
        LIMIT 1;
    END $$

    MySQL

    dmezentsev, 31 Октября 2011

    Комментарии (3)