Prev | Current Page 202 | Next

David Berube

"Practical Reporting with Ruby and Rails"

length==4
mysql_hostname,
mysql_username,
mysql_password,
mysql_database= *ARGV
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => mysql_hostname,
:username => mysql_username,
:password => mysql_password,
:database => mysql_database) # Establish a connection to the database.
class PaypalTransaction < ActiveRecord::Base
end
first = true
c = {}
sql = "
SELECT WEEK(p1.date) + 1 as week_number,
YEAR(p1.date) as year,
COALESCE((SELECT SUM(ABS(p2.gross))
FROM paypal_transactions as p2
WHERE (WEEK(p2.date) = WEEK(p1.date)
AND YEAR(p2.date) = YEAR(p1.date)
AND WEEKDAY(p2.date) IN (5,6)
AND p2.gross<0
AND p2.status='Completed')
),0) as weekend_amount,
CHAPTER 7 n TRACKING EXPENDITURES WITH PAYPAL 145
COALESCE((SELECT SUM(abs(p3.gross))
FROM paypal_transactions as p3
WHERE (WEEK(p3.date) = WEEK(p1.date)
AND YEAR(p3.date) = YEAR(p1.date)
AND WEEKDAY(p3.date) NOT IN (5,6)
AND p3.gross<0
AND p3.status='Completed')
),0) as weekday_amount
FROM paypal_transactions as p1
GROUP BY YEAR(date) ASC, WEEK(date) ASC;
"
weeks = []
max_gross=0.


Pages:
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
polski plakat Hotele Warszawa kozaki regały paletowe utylizacja komputerów