i




 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is WITH TIES clause in SQL?
02-08-2013, 05:25 AM
Post: #1
What is WITH TIES clause in SQL?
Quote:Suppose we want a report showing TOP(50) costly items. There may be a situation in which the price of 50th item is same as one or more items down the list. At that point how can we have a better solution? Do we want to include other products that are tied for the same prices as the item in the 50th position?

There is an easy way to solve the problem caused by tied values in the last position of your top list arbitrarily capping the results. And it the SQL clause With TIES

Code:
SELECT TOP 50 WITH TIES NAME, PRICE
FROM PRODUCT
ORDER BY PRICE DESC

Quote:The result set would have more than 50 items, but the last 2 or more items would be having the same price.






View Asad Ali's profile on LinkedIn

Quote


Possibly Related Threads...
Thread: Author Replies Views: Last Post
  What is COMPUTE clause in SQL? magnum_2007 0 1,614 02-03-2013 12:35 PM
Last Post: magnum_2007
  What is the difference between HAVING and WHERE clause? magnum_2007 0 1,158 02-03-2013 12:34 PM
Last Post: magnum_2007
  What is Group by clause in SQL? magnum_2007 0 836 01-31-2013 07:50 AM
Last Post: magnum_2007
  To delete duplicate rows in a table using Over Clause praveen 0 987 11-19-2012 12:14 PM
Last Post: praveen
  EXCEPT Clause in SQL Server is Similar to MINUS Clause in Oracle Shafiur Rahman 0 1,894 12-14-2010 09:39 AM
Last Post: Shafiur Rahman



User(s) browsing this thread: 1 Guest(s)