Categories
status

Connecting PostgreSQL from R using RdbiP …

Connecting PostgreSQL from R using RdbiPgSQL

library(RdbiPgSQL)
conn <- dbConnect(PgSQL(), host="localhost", dbname="my_database", user="my_user", password="my_secret_password")
res <- dbSendQuery(conn, "select * from prices where item_id = 29")
mydata <- dbGetResult(res)
...
dbDisconnect(conn)
Categories
status

How to select the first/least/max row pe …

How to select the first/least/max row per group in SQL

A nice explanation about the subject. Easy to understand.
http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/

Categories
status

Find duplicates in MySQL SELECT col1, …

Find duplicates in MySQL

SELECT col1, col2, count(col3)
FROM t1
GROUP BY col1, col2
HAVING count(col3) > 1

Adapted from
http://support.microsoft.com/default.aspx?scid=kb;en-us;139444