Reply to Re: SELECT UNTIL ?

Your name:

Reply:


Posted by Alex Kuznetsov on 11/30/06 16:44

Douglas,

For a limited number of images you can select all possible combinations
as follows:

DECLARE @n INT
SET @n = 5

SELECT P.Number AS Combination, N.Number
FROM
--- Numbers is a table with numbers from 0 to 9999
(SELECT Number FROM Numbers WHERE Number BETWEEN 0 AND (@n-1)) N
JOIN
(SELECT Number FROM Numbers WHERE Number BETWEEN 1 AND POWER(2,@n)) P
ON P.Number & POWER(2,N.Number) > 0
ORDER BY P.Number

-----------------------
Alex Kuznetsov
http://sqlserver-tips.blogspot.com/
http://sqlserver-puzzles.blogspot.com/

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация