Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
tadhg88
Yak Posting Veteran
62 Posts |
Posted - 2006-06-08 : 11:02:30
|
im tryin to get the numbers from 1 to 7 that have not been added to the table alreadythis is my Simple query select Day from foodmapping Group by Daywhich returns45so i need12367returned from this queryany ideas wud be appreciatedthanks in advance |
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2006-06-08 : 19:10:05
|
One way of doing it (in a stored proc)DECLARE @days TABLE (DayNum int)INSERT INTO @days(dayNum) SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7SELECT D.DayNum FROM foodmapping F RIGHT JOIN @days D ON D.DayNum = F.DayWHERE F.Day IS NULL |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-06-09 : 04:00:49
|
http://www.mindsdoor.net/SQLTsql/FindGapsInSequence.htmlMadhivananFailing to plan is Planning to fail |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
|
|
|
|