From: Brandon Weaver Date: 2012-09-20T04:23:37+09:00 Subject: Re: Ruby SQL Select Sum 2 Columns? On Sep 19, 2012, at 1:26 PM, Courtney Fay wrote: > Sorry, I don't know what either of those are. Here is a smaller > example, as I am just trying to get ruby to put a sql sum of a column, > based on a select statement. > > connection = java.sql.DriverManager.getConnection(db_url, user_name, > password) > sqlsame = "SELECT sum(myfield) AS sumDoc FROM " + table_var > statement = connection.prepareStatement(sqlsame) > rows = statement.execute_query > > puts sqlsame > puts statement > puts rows > > > I tried those puts, to get an output, and none of them give me the sum I > need. The puts sqlsame gives me the sql statement, which I can run in > sql and get the right number (which in this case is 8). > > the 2nd two puts give me this: > SQLServerPreparedStatement:7 > SQLServerResultSet:7 > > Which means nothing to me, lol. > > Does this make it more simple? > > Thanks for responding! > > -- > Posted via http://www.ruby-forum.com/. > You might look into Sequel or Active Records for SQL. They take quite a bit of the edge off of DB interaction.