# Miscellaneous > Structured Query Language (SQL) >  Sql/sas

## sc95123

Hello,

I need to know how can I split the population evenly between two groups. Naming one group C and the other D

For example:

Number of population = 100

Ouput:

Group C=50
Group D=50

Please help

Thanks,
Nikki

----------


## rmiao

On which rdbms? You mean split data in a table? Have more details?

----------


## sc95123

Well, I am pulling data from the table.  I have the total population so I am trying to split the total population into two groups for one column in the table.  I want to name these groups C and D

For example:
Column name Cells from table output
total population = 100

Output needs to be:
Cells         Population
C                50
D                50

Hope this helps. I think, I can do this using When statement but not sure

Thanks

----------


## rmiao

Do you want to split data based on value of other column or randomly?

----------


## sc95123

I have a program written in SAS and I want to distribute the total population into two groups evenly.  Just randomly. So I will need to create a new dataset for this. But I am not sure how to do this.

----------


## rmiao

Which rdbms do you use?

----------


## sc95123

I use Oracle

----------


## rmiao

May split them based on rowid.

----------


## sc95123

Ok.. Like how.

Could you help me with an example?

Thanks!

----------


## rmiao

Possible to post your table schema?

----------


## sc95123

It's too big to post it here.

It would be great if you can just show me an example on how to do it.  If you could tell me which statement to use....should I use if/else or when....I am not sure  and how should I divide them into two groups

----------


## rmiao

You want to split a table into two tables or what? If only need divide count in two groups to display, you can get it with count(*)/2.

----------


## sc95123

so how would I distribute the total number evenly into two groups?  I am not splitting the table. I only want to split the number into two groups.

For example:
total = 100

Output needs to be:
Group Total
C       50
D       50

----------


## rmiao

Set total/2 for each group. Is group a column in the table? Total means number of rows in the table?

----------


## aschk

The impression I get is that you have the following :

select column1 as population from table1

column1
100
200
300

this gives you all the population values, which i'm assuming you want to split in two, so...

select (column1 / 2) as group c, (column1 / 2) as group d from table1

group c  | group d
50         | 50
100       | 100
150       | 150

If this is not what you want, then you need to be clearer in what you are saying.

----------


## sc95123

Thanks.  This is exactly what I was looking for. This really helps. Thanks again

----------

