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 |
RaghaSM
Yak Posting Veteran
52 Posts |
Posted - 2008-04-22 : 09:34:28
|
Hi All,I have 2 tables :Levels Training------ ----------Levelid integer Companyid integerLevelName varchar Levelid integer A integer B integer C integer ModifiedDate DateTimeSuppose i have data like this in Training table:COmpanyid LevelName A B C ModifiedDate---------------------------------------------------------1 Level1 10 2 8 12/3/20081 Level3 11 4 7 12/4/20081 Level4 15 5 3 21/2/20081 level5 12 6 6 14/2/20082 Level1 10 4 6 2/3/20082 Level2 11 8 3 30/4/20082 Level3 5 5 0 25/2/20082 level4 12 9 3 23/2/2008I have 2 questions with this data :Question 1:-----------In the above data I have level 2 missing with respect to companyid 1 and level5 missing with respect to companyid 2, But I want to show my data as following :COmpanyid LevelName A B C ModifiedDate---------------------------------------------------------1 Level1 10 2 8 12/3/20081 Level2 0 0 0 Null or empty1 Level3 11 4 7 12/4/20081 Level4 15 5 3 21/2/20081 level5 12 6 6 14/2/20082 Level1 10 4 6 2/3/20082 Level2 11 8 3 30/4/20082 Level3 5 5 0 25/2/20082 level4 12 9 3 23/2/20082 Level5 0 0 0 Null or emptyHo wcan i fill all zeros for A B C columns with respect to the leveliname missing for a particular companyid.Question2:----------suppose my data has duplicate entries for a combination of companyid and levelid . SOmethis like this COmpanyid LevelName A B C ModifiedDate---------------------------------------------------------1 Level1 10 2 8 12/3/20081 Level1 45 10 35 15/3/20081 Level2 11 4 7 12/4/20081 Level2 15 5 3 21/2/20081 level3 12 6 6 14/2/20081 Level3 10 4 6 2/3/20081 Level2 11 8 3 30/4/20081 Level3 5 5 0 25/2/2008How to retrive all the training details for a particular company where with levelid and A B C columns for the latest modified date.I mean to say i want to retrive the data in this manner for the above data: one levelid fior each companyid with the data with latest modified dateCOmpanyid LevelName A B C ModifiedDate---------------------------------------------------------1 Level1 45 10 35 15/3/20081 Level2 11 8 3 30/4/20081 Level3 10 4 6 2/3/2008Please Help.............Needs the solution ASAPYour help will be verymuch appreciatedThanksRagha |
|
RaghaSM
Yak Posting Veteran
52 Posts |
Posted - 2008-04-22 : 09:58:18
|
I am sorry the data is not clear .Will post it again |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|