fixed complex_dat sql