OrderID (PK,PK,INT NOT NULL) ProductID (PK,PK,INT NOT NULL) UnitPrice (money,NOT NULL) Quantity (smallint ,NOT NULL)
ÏÖÔÚÒªÔÚÒ»ÌõSQLÓï¾äÖвé³ö max(Quantity) ºÍ Æä¶ÔÓ¦µÄ OrderID, min(Quantity)ºÍÆä¶ÔÓ¦µÄOrderID,µÃµ½Á½Ìõ¼Ç¼£¬¸ÃÔõÃ´Ð´ÄØ£¿ select OrderId, max(Quantity) from OrderDetails group by OrderId union select OrderId, min(Quantity) from OrderDetails group by OrderId
1Â¥Õý½â~~~~~` SQL code: select OrderId,Quantity from tb t where not exists(select 1 from tb where id>t.id) or not exists(select 1 from tb where id<t.id
ÐÞÕý
SQL code: select OrderId,Quantity from tb t where not exists(select 1 from tb where Quantity>t.Quantity) or not exists(select 1 from tb where Quantity<t.Quantity)