RowID Creativity

Last Post 31 Jul 2008 01:18 PM by SwePeso. 3 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Balance
New Member
New Member

--
29 Jul 2008 11:27 AM
Hi,

I need to output the value of an image rotating every 8 rows. My plan is to use a RowID with a series of CASE statements to output that image name. I'm having problems with the algorithm behind it, though. I need something like this:

SELECT
ROWID=IDENTITY(int,1,1),
c.contact_id AS CID,
c.fname,
c.lname
INTO CONTACTS2
FROM contacts c


SELECT
ImageName =
CASE
WHEN RowID/RowID = 0 THEN 'hahaha' ELSE 'boo!'
END,
* FROM CONTACTS2

Obviously this is wrong, as every row will output "boo!". The logic should be "if the RowID corresponds to the first position in that 8-row set, then output the first image. If it's the second RowID (ie: RowID=10) of the 8-row set, then output image 2", etc. Make sense?

TIA
Balance
New Member
New Member

--
29 Jul 2008 12:57 PM
I figured it out. I needed the Modulo operator
SQLUSA
New Member
New Member

--
29 Jul 2008 09:53 PM
Can you post the final solution script?
SwePeso
New Member
New Member

--
31 Jul 2008 01:18 PM
% 8 = {0..1..2..3..4..5..6..7} depending on which record you want.
You are not authorized to post a reply.

Acceptable Use Policy