Hi there! Yes, there is a way to defeat Sans. If you pay attention to his dialogue right before he falls asleep, he hints as to what to do. All you need to beat him is on that screen.
--FIGHT SPOILERS--
Click and drag the dialogue box at the bottom. You'll see that there's something hiding there.