March 19, 2004 at 8:55 am
need help
How can i show in Table evry third OR fourth record (row)
in my table i have 5600 Records
and i wont to do like this
----------------------------------
--------------------------------------------
1 i wont to show only the RED (aaaaaaaaaaaaa)
and insert the RED new table
------------------------------------
2 i wont to insert the green (bbbbbbbbbbb)
in a new table
------------------
and the C also
and the D also
thnks ilan
March 19, 2004 at 10:06 am
Is there anything in the table to differentiate the records? Why do you need to move the data to other tables?
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
March 19, 2004 at 10:28 am
Like this:
ALTER TABLE
ADD COLUMN rowid int IDENTITY(1,1)
GO
select *
from table
where rowid % 3 = 0
March 19, 2004 at 2:24 pm
Ok it work
now The big problem How can i do this ?
---------------------
fld1 fld2 fld3 fld4
-------------------------------------------------------------------------
thnks ilan
March 19, 2004 at 4:30 pm
Something like this maybe with the structure you were given to use with the extra idenitity column (which for this cannot be missing any numbers or you will get null gaps in the output).
SELECT
CEILING(rowid/4.0) rowflow,
MAX(CASE WHEN (rowid - 1) % 4 = 0 then val end) fld1,
MAX(CASE WHEN (rowid - 2) % 4 = 0 then val end) fld2,
MAX(CASE WHEN (rowid - 3) % 4 = 0 then val end) fld3,
MAX(CASE WHEN (rowid) % 4 = 0 then val end) fld4
FROM tblName
GROUP BY
CEILING(rowid/4.0)
March 21, 2004 at 11:55 pm
thnks it work
100%
ilan
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply