Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display even entries only 2

Status
Not open for further replies.

denTom

Technical User
Oct 11, 2004
2
BE
Basically I have a table filled with wavelength and power readings from an optical sensor (sensor is being read every 15 mins) which I'm using to create graphs in Labview.

Plotting a full table takes a ton of time though, so I'm basically in need of a function that displays every 4th entry.

Now my SQL "skill" is crap to say the least, yet I figured "how hard could it be?" and had a go at it. I failed misearbly; 3 hours later and not a single usefull line of code later, I'm turning to you lot.

the main problem is is that the ID of the row doesn't have anything to do with where it is located.

ID Data
5 -60.0dB <-- entry 1
33 -58.3dB <-- entry 2
48 -59-2dB <-- entry 3
55 -58.6dB <-- entry 4

only entry 4 needs to be displayed :/

anyone here who has an idea how to do this?
 
How are the data ordered (sequenced) ?
If by ID, you may try something like this:
SELECT ID, Data FROM yourTable A
WHERE (SELECT Count(*) FROM yourTable B WHERE B.ID<=A.ID) MOD 4 = 0

Depending on your DBMS, the MOD operator may have to be replaced by a Mod function, like this:
WHERE Mod((SELECT Count(*) FROM yourTable B WHERE B.ID<=A.ID),4)=0

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
awesome \o/

works absolutely perfect :D

thnx man :)

*does little dance*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top