Making a query

Forum with tips, support, etc, on using the PostgreSQL database with Poker Tracker. Please post any PostgreSQL questions here.

Making a query

Postby kmasonbx » Sat Apr 11, 2009 7:56 pm

I need to do a tax query, and I have what I think is the text needed to make the query but I have no idea where I'm supposed to input the text.

Here is the text that I have, is this right?

SELECT date_part('month',s.session_start) AS SessionMonth, date_part('day',s.session_start) AS SessionDay, date_part('year', s.session_start) AS SessionYear, SUM(amount_won) AS AmountWon
FROM players AS p INNER JOIN session AS s ON s.player_id=p.player_id
WHERE p.screen_name='SCREENNAME' AND date_part('year', s.session_start) = YEAR
GROUP BY SessionMonth, SessionDay, SessionYear
ORDER BY SessionYear, SessionMonth, SessionDay;

Change SCREENNAME, YEAR to your main screenname in PT2 and the tax year in question.
kmasonbx
 
Posts: 63
Joined: Fri Mar 07, 2008 2:32 am

Re: Making a query

Postby ptrack pat » Sat Apr 11, 2009 9:46 pm

You need to use the pgAdmin program to connect to your database and run the query. Go to the Start > Programs > PostgreSQL > pgAdmin then right-click on the red X and select connect from the popup menu. Enter your PostgreSQL password when prompted. Then click on your database and then under the Tools menu select Query Tool. Enter this SQL statement into the next window.
ptrack pat
 
Posts: 4841
Joined: Sun Dec 09, 2007 12:38 pm

Re: Making a query

Postby kmasonbx » Sun Apr 12, 2009 12:36 pm

I did this but when I highlight my database and click on tools the query tool option isn't selectable. The only selectable options are connect, stop service, reports, server configuration and server status. Am I doing something wrong?
kmasonbx
 
Posts: 63
Joined: Fri Mar 07, 2008 2:32 am

Re: Making a query

Postby ptrack pat » Sun Apr 12, 2009 1:58 pm

If you are connected to the database then it should be enabled. What database are you clicking on? Is there a red X next to it? If there is a red X next to it you aren't connected.
ptrack pat
 
Posts: 4841
Joined: Sun Dec 09, 2007 12:38 pm

Re: Making a query

Postby kmasonbx » Sun Apr 12, 2009 4:13 pm

I was just in the wrong place got the query tool to come up. However that query doesn't seem to be working. Is something wrong within the text? If so do you know a query that will work in order to have my wins and losses seperated for each month for 2008?
kmasonbx
 
Posts: 63
Joined: Fri Mar 07, 2008 2:32 am

Re: Making a query

Postby ptrack pat » Sun Apr 12, 2009 4:49 pm

Is it giving you an error message?
ptrack pat
 
Posts: 4841
Joined: Sun Dec 09, 2007 12:38 pm

Re: Making a query

Postby kmasonbx » Sun Apr 12, 2009 11:23 pm

It was my error, I was changing the wrong 'year.' It worked, thanks for all your help.
kmasonbx
 
Posts: 63
Joined: Fri Mar 07, 2008 2:32 am


Return to PostgreSQL Forum

Who is online

Users browsing this forum: No registered users and 0 guests