473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Select records which have continuous values in a column

I have a table with 3 columns. The first column has Hexadecimals. The second column has the corresponding binary numbers. The third colmn has boolean values.
I need to select 4 records where the colC is False for the 4 records, the last two digits of the first record's colB (Binary value) are 00 and the other 3 records' ColB are the next consecutive binary numbers.
After selecting the records, Col C of those records must be updated to True.
I need these in a SQL function.
Oct 16 '13 #1
5 2167
Rabbit
12,516 Expert Mod 8TB
I have trouble following what you're trying to do. It would help to see sample data and results. Also, post what you've tried so far and any error messages that you get. What version of SQL Server are you using. Don't forget to use code tags when posting any code or formatted data.
Oct 16 '13 #2
Luuk
1,047 Expert 1GB
if i read this, i think he means:
Expand|Select|Wrap|Line Numbers
  1. select colA, colB, colC
  2. from tablename
  3. where colC=false 
  4.   and colB>=(select colB 
  5.             from tablename
  6.             where right(colB,2)="00")
  7.  
limiting the output to 4 records in mssql is beyond my knowledge ;)
Oct 16 '13 #3
Rabbit
12,516 Expert Mod 8TB
In MS SQL, you use SELECT TOP #.

That query might error out. Your subquery can return more than one row.
Oct 16 '13 #4
@Rabbit
Hello!
I tried to simplify my question here. Hope you can understand what I mean.

ColA has numbers like 450, 451, 452, ….
ColB has Binary numbers like 1000,1001,1010,…..
ColC has values like Free, Assigned, Assigend, Free….

I need to select a group of 4 records where the first record’s binary number ends with 00, the Col C is Free and the ColB must have consecutive numbers like 455, 456,457, 458
Oct 17 '13 #5
Rabbit
12,516 Expert Mod 8TB
That's an odd and specific requirement... Anyways, join the table to itself 3 times. One join for each consecutive row that you need.
Oct 17 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Danny | last post by:
How to allow users to select a set of records and then let them change a field for all these records at once? I would like to do this in code on a form. I will have a form with tabular view of...
1
by: arthur-e | last post by:
How can you select records based on more than one combo box - I have a combobox that selects records based on name (I'm sure this has been asked a thousand times - web site answer/link could be...
1
by: Dan Sikorsky | last post by:
How do you select records from one dataset and create a second dataset? I need to pull out the master records from a dataset and create a master datagrid in which to embed a details datagrid (for...
1
by: francophone77 | last post by:
What is the best way to setup a query to select records in specific months only. For instance if I want to compare sales in the month of May regardless of year. TIA
4
by: paulquinlan100 | last post by:
Hi I have the following query: SELECT qryBlackbook.* FROM qryBlackbook inner JOIN qryLatestMeetingDate ON (qryBlackbook.Site_Ref = qryLatestMeetingDate.Site_Ref) AND...
2
by: JC2710 | last post by:
Hi I would like a Query that Updates a field to indicate that records have a duplicate entry( records with same values). My table is ..... Code........Process..........Quantity ...
2
by: Hamayun Khan | last post by:
Hi all I am using the following query to select records for table Select JobTitle,JobDesc,Scraped,logoimage,JobPostID,SchoolID,web,MemType,InstitutionName,PayScale,LEA,Contract as...
2
by: rkferguson | last post by:
Hi Folks, I have a table that captures information about documents that leave the office. Some of those documents may get a signature and then return to the office. Need away to query the...
0
by: Elizabeth Mitte | last post by:
Hello, Thank you for the tutorial type article, is proving very useful. However, I have been following your instructions step by step and still get errors with the code? Trying to create the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.