Splitting dataset in 2 parts

Last Post 14 Aug 2012 09:31 AM by richard forhire. 2 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
New Member
New Member

22 Mar 2012 01:28 PM
Hi, I have 5 records in a table called "testing" as such: LetterCd contact_id x 1 x 2 x 3 x 4 x 5 How can I split this dataset so that three records have LetterCd = 'y' and the other 2 records have LetterCd = 'x'? The number of records can vary, but the idea is the same: split the values in the LetterCd column evenly (50% = 'x', 50% = 'y'). I can't update the data, it would have to be a SELECT statement with some sort of CASE statement to get the remainder of the record count? TIA
New Member
New Member

22 Mar 2012 04:34 PM
Don't understand exactly. Are you trying to SPLIT the values returned? Perhaps you could show some sample data and the expected result.
richard forhire
New Member
New Member

14 Aug 2012 09:31 AM
use AdventureWorks2008R2

create table testing (contact_id int, LetterCD varchar(50))
insert into testing values (1,'a'), (2,'b'), (3,'c'), (4,'d'), (5,'e')

select * from testing
where abs(contact_id) % 2 = 1
-- odd numbered columns only

Acceptable Use Policy