select C.companyName, o.orderId from customers c inner join orders o
on c.customerID = o.customerID order by companyName
This is the result of the above query
Alfreds Futterkiste 10835
Alfreds Futterkiste 10952
Alfreds Futterkiste 11011
Ana Trujillo Emparedados y helados 10926
Ana Trujillo Emparedados y helados 10759
------------------------------------------------------------------------------------------------------------
Q: How to get the following result?
Alfreds Futterkiste 10835
null 10952
null 11011
Ana Trujillo Emparedados y helados 10926
null 10759
on c.customerID = o.customerID order by companyName
This is the result of the above query
Alfreds Futterkiste 10835
Alfreds Futterkiste 10952
Alfreds Futterkiste 11011
Ana Trujillo Emparedados y helados 10926
Ana Trujillo Emparedados y helados 10759
------------------------------------------------------------------------------------------------------------
Q: How to get the following result?
Alfreds Futterkiste 10835
null 10952
null 11011
Ana Trujillo Emparedados y helados 10926
null 10759