A compound represented by the following formula or a salt thereof, which has an GPR119 agonist action, is useful for the prophylaxis or treatment of diabetes, obesity and the like, and shows superior efficacy:whereinP: substituted 6-membered aromatic ring,Q: (substituted) 6-membered aromatic ring,A1: CR4aR4b, NR4c, O, S, SO or SO2 {R4a-4c: H etc.},L1: (substituted) C1-5 alkylene,L2: a bond or (substituted) C1-3 alkylene,L3-4: (substituted) C1-3 alkylene,R1: H, X, CN, (substituted) hydrocarbon, (substituted) heterocycle or (substituted) OH, or (substituted) 4- to 8-membered (heterocyclic) ring together with A1,R2: H, CN, (substituted) hydrocarbon, andR3a: —COSRA1, (substituted) 5- or 6-membered aromatic ring {RA1: (substituted) hydrocarbon or (substituted) heterocycle}.