[select ( ( CASE WHEN unix_timestamp( haya_st_date ) <= unix_timestamp(now()) && unix_timestamp( haya_ed_date ) >= unix_timestamp(now()) && w_code & 1 THEN 1 ELSE 0 END ) + ( CASE WHEN unix_timestamp( guru_st_date ) <= unix_timestamp(now()) && unix_timestamp( guru_ed_date ) >= unix_timestamp(now()) && w_code & 2 THEN 2 ELSE 0 END ) + ( CASE WHEN unix_timestamp( guruhaya_st_date ) <= unix_timestamp(now()) && unix_timestamp( guruhaya_ed_date ) >= unix_timestamp(now()) && w_code & 4 THEN 4 ELSE 0 END ) + ( CASE WHEN unix_timestamp( gaku_st_date ) <= unix_timestamp(now()) && unix_timestamp( gaku_ed_date ) >= unix_timestamp(now()) && w_code & 8 THEN 8 ELSE 0 END ) + ( CASE WHEN unix_timestamp( josei_st_date ) <= unix_timestamp(now()) && unix_timestamp( josei_ed_date ) >= unix_timestamp(now()) && w_code & 16 THEN 16 ELSE 0 END ) + ( CASE WHEN unix_timestamp( nenrei_st_date ) <= unix_timestamp(now()) && unix_timestamp( nenrei_ed_date ) >= unix_timestamp(now()) && w_code & 32 THEN 32 ELSE 0 END ) + ( CASE WHEN unix_timestamp( natsu_st_date ) <= unix_timestamp(now()) && unix_timestamp( natsu_ed_date ) >= unix_timestamp(now()) && w_code & 64 THEN 64 ELSE 0 END ) + ( CASE WHEN unix_timestamp( haru_st_date ) <= unix_timestamp(now()) && unix_timestamp( haru_ed_date ) >= unix_timestamp(now()) && w_code & 128 THEN 128 ELSE 0 END ) + ( CASE WHEN unix_timestamp( superhaya_st_date ) <= unix_timestamp(now()) && unix_timestamp( superhaya_ed_date ) >= unix_timestamp(now()) && w_code & 256 THEN 256 ELSE 0 END ) + ( CASE WHEN unix_timestamp( aki_st_date ) <= unix_timestamp(now()) && unix_timestamp( aki_ed_date ) >= unix_timestamp(now()) && w_code & 512 THEN 512 ELSE 0 END ) ) as waribiki_code , wari_bikou from waribiki_tbl_tds where d_code_g = ]
error

ErrorReport
-- NGSQL --
select
            (
                ( CASE WHEN unix_timestamp( haya_st_date ) <= unix_timestamp(now()) &&
                 unix_timestamp( haya_ed_date ) >= unix_timestamp(now()) &&
                 w_code & 1 THEN 1 ELSE 0 END
                )
                +
                ( CASE WHEN unix_timestamp( guru_st_date ) <= unix_timestamp(now()) &&
                            unix_timestamp( guru_ed_date ) >= unix_timestamp(now()) &&
                            w_code & 2 THEN 2 ELSE 0 END
                )
                +
                ( CASE WHEN unix_timestamp( guruhaya_st_date ) <= unix_timestamp(now()) &&
                            unix_timestamp( guruhaya_ed_date ) >= unix_timestamp(now()) &&
                            w_code & 4 THEN 4 ELSE 0 END
                )
                +
                ( CASE WHEN unix_timestamp( gaku_st_date ) <= unix_timestamp(now()) &&
                            unix_timestamp( gaku_ed_date ) >= unix_timestamp(now()) &&
                            w_code & 8 THEN 8 ELSE 0 END
                )
                +
                ( CASE WHEN unix_timestamp( josei_st_date ) <= unix_timestamp(now()) &&
                            unix_timestamp( josei_ed_date ) >= unix_timestamp(now()) &&
                            w_code & 16 THEN 16 ELSE 0 END
                )
                +
                ( CASE WHEN unix_timestamp( nenrei_st_date ) <= unix_timestamp(now()) &&
                            unix_timestamp( nenrei_ed_date ) >= unix_timestamp(now()) &&
                            w_code & 32 THEN 32 ELSE 0 END
                )
                +
                ( CASE WHEN unix_timestamp( natsu_st_date ) <= unix_timestamp(now()) &&
                            unix_timestamp( natsu_ed_date ) >= unix_timestamp(now()) &&
                            w_code & 64 THEN 64 ELSE 0 END
                )
                +
                ( CASE WHEN unix_timestamp( haru_st_date ) <= unix_timestamp(now()) &&
                            unix_timestamp( haru_ed_date ) >= unix_timestamp(now()) &&
                            w_code & 128 THEN 128 ELSE 0 END
                )
                +
                ( CASE WHEN unix_timestamp( superhaya_st_date ) <= unix_timestamp(now()) &&
                            unix_timestamp( superhaya_ed_date ) >= unix_timestamp(now()) &&
                            w_code & 256 THEN 256 ELSE 0 END
                )
                +
                ( CASE WHEN unix_timestamp( aki_st_date ) <= unix_timestamp(now()) &&
                            unix_timestamp( aki_ed_date ) >= unix_timestamp(now()) &&
                            w_code & 512 THEN 512 ELSE 0 END
                )
            )
            as waribiki_code
            , wari_bikou
            from waribiki_tbl_tds
            where
            d_code_g =

-- ErrorMsg --
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 57

-- ErrorCode --
1064