Worth noting that if you have multiple purchases of the same share & you only sell part of your holding you can choose which parcels of shares you actually sold. There isn't a first in first out or last in last out rule, nor an average cost requirement. For instance if you have a large loss for the year there's no point in selling a parcel you've held > 12 months and wasting the potential discount if you're not going to exceed the losses for the year.
Also the 12 months doesn't include the day you buy & the day you sell when calculating the period held.
Also relevant is the 30 day rule. If you sell & buy back the same shares within 30 days for tax purposes it is deemed that thevtransaction didn't occur when claiming losses etc. Known as 'bed & breakfasting' in some circles.