私が得たいのは、「最初に5つの別個の顧客の注文ID値を取得する」ことです。私はクエリを5に制限すると、最初の4つの顧客の注文ID値が期待通りに返されます(ホーンの周りに2つの異なる注文IDがあります)。最初の5つの別個の顧客の注文ID値を取得する方法はありますか?最初のn個の列の値を左結合から取得する方法は?
SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;
CustomerName OrderID
Alfreds Futterkiste 10001
Ana Trujillo Emparedados y helados 10308
Antonio Moreno Taquería 10365
Around the Horn 10355
Around the Horn 10383
B's Beverages 10289
Antonio baa 10444
.... ....
編集:私は取得したい何は最初の5個別の顧客です。
Alfreds Futterkiste 10001 (first customer)
Ana Trujillo Emparedados y helados 10308 (second customer)
Antonio Moreno Taquería 10365 (third customer)
Around the Horn 10355 (forth customer)
Around the Horn 10383 (forth customer)
B's Beverages 10289 (fifth customer)
ここではare私が取り組んでいるテーブル。これを試してみてください
http://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-veryを参照してください。 -simple-sql-query – Strawberry
@Strawberry不明な点はありますか? – hellzone
明らかに。それ以外の場合は、すでに回答を受け入れていたでしょう – Strawberry