Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
limericklad1974
Starting Member
39 Posts |
Posted - 2012-05-08 : 10:23:37
|
| Hi thereI have a database table with 6 columnsIDTest1Test2Test3test4Test5The data in my table looks like this1 NULL NULL 3.01 4.98 NULL2 NULL 4.39 3.97 NULL 8.753 NULL 5.54 NULL NULL 6.544 2.45 NULL NULL NULL 8.74What I need to do is create little tables, where I group the data from column 2 and 5 for example...The result needs to be something like this (for grouping column 2 and 6)2 NULL 8.753 NULL 6.544 2.45 8.74So, I would need to ignore row 1 because columns 2 and 6 have a NULL value but I would want to display rows 2 and 3 even though column 2 has a NULL, column 6 has data |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-08 : 11:04:03
|
You need multiple inserts for thisINSERT INTO Table1Select Test1,Test5FROM tableWHERE Test1 IS NOT NULLOR Test5 IS NOT NULL... Can i ask reason for splitting the data into smaller tables like this? Are you aware that by doing this you're increasing data redundancy? How are you planning to keep these child tables consistent with master tables reg. DML operations taking place on master?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
limericklad1974
Starting Member
39 Posts |
Posted - 2012-05-08 : 11:45:46
|
quote: Originally posted by visakh16 You need multiple inserts for thisINSERT INTO Table1Select Test1,Test5FROM tableWHERE Test1 IS NOT NULLOR Test5 IS NOT NULL... Can i ask reason for splitting the data into smaller tables like this? Are you aware that by doing this you're increasing data redundancy? How are you planning to keep these child tables consistent with master tables reg. DML operations taking place on master?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Sorry I didnt mean to give the impression I wanted to split the data into further tables. What I want to do is create some stored precedures to view the data, but I dont want to view the entire dataset, I just want to display certain columnsfor instance, column 2 and 6 might be related so I want to display a table of results with just these two columns displayed.Are you sure your code will work for this? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-08 : 11:55:10
|
if you just want retrieval remove that insert partSelect Test1,Test5FROM tableWHERE Test1 IS NOT NULLOR Test5 IS NOT NULL... Based on columns you want you can change column names in select as well as in where aboveAre you sure your code will work for this?why not try it and see for yourself?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
limericklad1974
Starting Member
39 Posts |
Posted - 2012-05-08 : 12:40:19
|
quote: Originally posted by visakh16 if you just want retrieval remove that insert partSelect Test1,Test5FROM tableWHERE Test1 IS NOT NULLOR Test5 IS NOT NULL... Based on columns you want you can change column names in select as well as in where aboveAre you sure your code will work for this?why not try it and see for yourself?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
I think I oversimplified the problem... it seems like there is another stored procedure running in the background of the page I am working on....I will try to get a better explanation sorted out and get the database tables, data and procedures up here for someone to look at |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-08 : 12:44:01
|
| Ok..that sounds fineUnless you give full background we wont be able to get full picture as we dont have access to your system!------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|