Re: interesting problem

From: David Portas (REMOVE_BEFORE_REPLYING_dportas_at_acm.org)
Date: 08/13/04


Date: Fri, 13 Aug 2004 08:42:14 +0100

It's useful to keep a table of Numbers in your database to help with queries
like this:
http://www.bizdatasolutions.com/tsql/tblnumbers.asp

Now try:

SELECT number
 FROM Numbers,
 (SELECT MIN(n), MAX(n)
  FROM YourTable) AS T(min_n, max_n)
 WHERE number BETWEEN min_n AND max_n

-- 
David Portas
SQL Server MVP
--


Relevant Pages

  • Re: reindex or update stat
    ... change in the way the queries are run. ... Andrew J. Kelly ... SQL Server MVP ... > I have a database that will have couple thousands row inserted normally, ...
    (microsoft.public.sqlserver.server)
  • Re: Eliminating Dynamic SQL
    ... If you have the same table structures in each database then you can ... create a partitioned view across them and reference the partitioned ... David Portas ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Display Money Type using + and -
    ... Why would you do this in the database? ... And why are you using a MONEY ... David Portas ... SQL Server MVP ...
    (comp.databases.ms-sqlserver)
  • Re: Database Design setup
    ... Sounds like you only need to store the full path once per user. ... sensible to put the path in a Users table in your database. ... David Portas ... SQL Server MVP ...
    (microsoft.public.sqlserver.server)
  • Re: Row Number in SQL Server
    ... If it's not for presentation but for use in another query/process then there ... Perhaps the two queries could be combined in some way ... David Portas ... SQL Server MVP ...
    (microsoft.public.sqlserver.programming)