Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server CE / May 2008

Tip: Looking for answers? Try searching our database.

sql query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SQL-Asheq - 13 May 2008 10:43 GMT
I want to find missing data from a table. For example there are 1,2,5,7 in a
table. Here max is 7 and min is 1. Now missing data within max and min are
3,4,6. So how can find missing data.
Paul G. Tobey [eMVP] - 13 May 2008 16:13 GMT
Seems like you'd enumerate all of the rows, keep a bit map where each bit
corresponds to a single value being present and set to 1 those bits that you
find.  Once you've done that, all bits still set to zero are those which are
missing.  Why does this sound like a homework assignment?

Paul T.

>I want to find missing data from a table. For example there are 1,2,5,7 in
>a
> table. Here max is 7 and min is 1. Now missing data within max and min are
> 3,4,6. So how can find missing data.
Jin - 13 May 2008 19:06 GMT
On May 13, 4:43 am, SQL-Asheq <SQL-As...@discussions.microsoft.com>
wrote:
> I want to find missing data from a table. For example there are 1,2,5,7 in a
> table. Here max is 7 and min is 1. Now missing data within max and min are
> 3,4,6. So how can find missing data.

Strange question, but I'll bite.

Create another table containing all the valid values (1 - 7).
Then perform a query using NOT EXISTS() as in:

SELECT * FROM ValidValues
WHERE NOT EXISTS (SELECT 1 FROM ActualValues WHERE ActualValues.Value
= ValidValues.Value)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.