Hi, Im trying to complete a list of jobs using SQL Querries and some "if else" commands but im stucked in some steps. Could any of you give me some help? -in COLUMN1 change the format 20JAN2000:00:00:00 to 20JAN2000 and exclude every row that date is different from 20. -extract the first character in COLUMN2 and creat COLUMN3 with that value ex: COL2,COL3 135,1 461,4 247,2 -in every row in which COL3=5, value in COLUMN4=value in COLUMN5 -create COLUMN7 where if COLUMN6="north" then COLUMN7 value="N" else COLUMN7 value="X" Ill be grateful for any help, thnks -- View this message in context: http://www.nabble.com/Some-SQL-Challenges-tp24795946p24795946.html Sent from the R help mailing list archive at Nabble.com.
To insert values with SQL: INSERT INTO table_name VALUES (value1, value2, value3,...). To deal with those date problems Im almost sure that R has a Date Function somewhere in its manual. You should take a look. Just the best help I can give, sorry good look JoK LoQ wrote:> > Hi, > > Im trying to complete a list of jobs using SQL Querries and some "if else" > commands but im stucked in some steps. Could any of you give me some help? > > -in COLUMN1 change the format 20JAN2000:00:00:00 to 20JAN2000 and exclude > every row that date is different from 20. > -extract the first character in COLUMN2 and creat COLUMN3 with that value > ex: > COL2,COL3 > 135,1 > 461,4 > 247,2 > -in every row in which COL3=5, value in COLUMN4=value in COLUMN5 > -create COLUMN7 where if COLUMN6="north" then COLUMN7 value="N" else > COLUMN7 value="X" > > Ill be grateful for any help, thnks >-- View this message in context: http://www.nabble.com/Some-SQL-Challenges-tp24795946p24834191.html Sent from the R help mailing list archive at Nabble.com.
Don't understand what this has to do with SQL, or why you're asking for SQL solutions in an R mailing list, but here are some R suggestions. (abbreviating "COLUMN" with "C") At 11:40 AM -0700 8/3/09, JoK LoQ wrote:>Hi, > >Im trying to complete a list of jobs using SQL Querries and some "if else" >commands but im stucked in some steps. Could any of you give me some help? > >-in COLUMN1 change the format 20JAN2000:00:00:00 to 20JAN2000 and exclude >every row that date is different from 20.Assuming C1 contains character strings: C1 <- substring( C1, 1, 9) C1 <- C1[ substring(C1,1,2) == '20' ]>-extract the first character in COLUMN2 and creat COLUMN3 with that value >ex: >COL2,COL3 >135,1 >461,4 >247,2C3 <- substring( C2, 1 ,1) or C3 <- as.numeric( substring( C2, 1, 1) )>-in every row in which COL3=5, value in COLUMN4=value in COLUMN5C4[ C3==5] <- C5[ C3==5]>-create COLUMN7 where if COLUMN6="north" then COLUMN7 value="N" else COLUMN7 >value="X"C7 <- ifelse( C6 == "north" , "N", "X")> >Ill be grateful for any help, thnks >-- >View this message in context: >http://*www.*nabble.com/Some-SQL-Challenges-tp24795946p24795946.html >Sent from the R help mailing list archive at Nabble.com. > >______________________________________________ >R-help at r-project.org mailing list >https://*stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://*www.*R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.-- -------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062