The two most common types of orders that can be placed when buying a security are market orders and limit orders.
Market orders are executed promptly at the best available price, which in the case of a buy order is the lowest price a prospective seller is willing to accept. If the buyer wants more shares than the lowest asking party is offering, the remaining shares would be sold to the next-lowest ask price and so on until all shares requested were purchased.
For example, a buyer places a market order for 10,000 shares of stock X. The lowest ask price is offering 5,000 shares at $100 and these are filled. The next lowest ask price is for 3,000 shares at $100.25 and these are filled. The third-lowest ask price is for 5,000 shares at $100.50 and 2,000 of these are filled to complete the order. The effective purchase price is ((5,000 X 100) + (3,000 X 100.25) + (2,000 X 100.50))/10,000 = $100.175
Market orders emphasize prompt execution, and in return result in accepting some uncertainty as to the actual execution price.
Limit orders are instructions to accept only those prices that are better than a designated limit, including a time (end of day, good-til-canceled, etc) at which the order will expire.
For example, the buyer above may specify that the order has a $100.25 limit price. In that case, 5,000 shares would be executed at $100 and 3,000 at $100.25. The others would remain on order until a prospective seller was willing to accept $100.25 or less. The average price at execution would be ((5,000 X 100) + (3,000 X 100.25))/8,000 = $100.09375. If the remaining 2000 shares were executed at $100.25 the effective price would be ((5,000 X 100) + (5,000 X 100.25))/10,000 = 100.125.
Limit orders emphasize price at the expense of uncertainty as to whether the order will be filled in entirety.