Hello,

I have a script that pulls data from 4 tables and I want to pull data from one more table with this script. The fifth table is called "EFT_TRANS" and I want to query data from "Amount" Field. The linking field in the "EFT_TRANS" table is "Player_ID", I think. This data needs to be in a fifth column in the query results.

i had some help writing this original script below and I know what it does but I don't totally understand all of the functions like the (sub select) and group by. Any help would be greatly appreciated.

__________________________________________________ __

/* This script selects by given date range, a players Player_ID, Firstname, Lastname, address, city,
state, zip, Total Number of trips and total coin in. */



SELECT P.player_ID, p.FirstName, p.LastName, a.Address1A, a.Address1b, a.City1, a.State1, a.Zip1,
x.stattype, x.NumTrips, X.cashin

FROM CDS_PLAYER p, cds_account a,
(select st.meta_id as player_ID, sd.stattype, sum(sd.CashIn)as cashin, count(st.stattrip_id) as NumTrips

FROM CDS_STATTRIP st, CDS_StattripDetail sd

WHERE st.idtype = 'p'

AND st.StartGamingDate between '02/01/2009' and '02/28/2009' /* Enter Gaming Date range here */

AND st.stattrip_id = sd.stattrip_id

GROUP BY st.meta_id, sd.stattype)x

WHERE x.player_id = p.player_id

AND p.account_id = a.account_id

ORDER BY p.player_id, stattype

----------------------------------------------------------
Results

player_ID,FirstName,LastName,Address1A,Address1b,C ity1,State1,Zip1,stattype,NumTrips,cashin,AvgPerTr ip
12,CINDY,MIL,P.O. BOX 8,,WILLITS,CA,95490,SLOT,7,$198.50 ,$28.36
13,EARNEST,POTT,50 SOUTH MAIN STREET #49,,WILLITS,CA,95490,SLOT,2,"$1,400.36 ",$700.18
14,THELMA,DD,18 LOCUST STREET #8,,WILLITS,CA,95490,SLOT,17,"$10,601.89 ",$623.64
15,RAELENE,DOERO,10 BAECHTEL RD,,WILLITS,CA,95490,SLOT,2,$382.89 ,$191.45
17,ROBERT,SHOAW,1 OSPREY COURT,,FORT