The sonata in G major for two flutes and basso continuo, BWV 1039 is a trio sonata by Johann Sebastian Bach. It has four movements:
This sonata, scored for two transverse flutes and continuo, is one of the few trio sonatas that can genuinely be attributed to Bach. Although traditionally thought to have been composed during Bach's period in Weimar or Cöthen, Bach scholars have revised that dating based on an analysis of the extant manuscripts and on stylistic considerations. According to Wolff (1994), the trio sonata was composed between 1736 and 1741 in Leipzig, where, since 1729, Bach had been director of the Collegium Musicum, a chamber music society performing weekly at the Café Zimmermann. The version for viola da gamba and harpsichord, BWV 1027, as well as the other two sonatas for this ensemble, are dated by Laurence Dreyfus, Christoph Wolff and others to the same period.
There is a third version for organ, the trio sonata in G major in three movements (BWV 1039a and BWV 1027a): its first two movements are organ transcriptions of the first two movements of BWV 1039; its last movement is a transcription of the fourth movement of BWV 1027. According to the Bach scholar Russell Stinson, the transcription for organ was not made by Bach, but probably by Johann Peter Kellner.