Sequential temporal ordering and patterning are key features of natural signals used by the brain to decode stimuli and perceive them as sensory objects. To explore how cortical neuronal activity underpins sequence recognition, we developed a task in which mice distinguished between tactile 'words' constructed from distinct vibrations delivered to the whiskers, assembled in different orders. Animals licked to report the presence of the target sequence. Mice could respond to the earliest possible cues allowing discrimination, effectively solving the task as a 'detection of change'problem, but enhanced their performance when deliberating for longer. Optogenetic inactivation showed that both primary somatosensory 'barrel' cortex (S1bf) and secondary somatosensory cortex were necessary for sequence recognition. Twophoton imaging of calcium activity in S1bf layer 2/3 revealed that, in well-trained animals, neurons had heterogeneous selectivity to multiple task variables including not just sensory input but also the animal's action decision and the trial outcome (presence or absence of a predicted reward). A large proportion of neurons were activated preceding goal-directed licking, thus reflecting the animal's learnt response to the target sequence rather than the sequence itself; these neurons were found in S1bf as soon as mice learned to associate the rewarded sequence with licking. In contrast, learning evoked smaller changes in sensory responses: neurons responding to stimulus features were already found in naïve mice, and training did not generate neurons with enhanced temporal integration or categorical responses. Therefore, in S1bf sequence learning results in neurons whose activity reflects the learnt association between the target sequence and licking, rather than a refined representation of sensory features.