Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
azmark30
Starting Member
11 Posts |
Posted - 2007-11-30 : 12:01:35
|
OK here's what Im trying to do..ROOM Points for -OUT OF TOWN PLAYERS-only last 10 days of tracked play count in room point calculation.we look at the last 18 months for the tracked 10 days of play.a player must earn a full 100 points in 24 hours to get 1 room point.if player earns 500 he then gets 5 room points in that 24 hours..the most a player can earn is 30 points per 2 month period.ROOM POINTS for LOCAL PLAYERS - 10 days tracked play we look at the last 3 months for the tracked 10 days.a local will earn half a point for every 100 points earned in 24 hours. if he earns 500 points he will get 21 1/2 room points.i tried to write something but i can not get it right.. when i try this sql query it shows what i need but when it does the (c.ptsearned) /100 /2 it makes it a 0 it rounds the .49 to a 0..playerid first last local points date roompoints209802 MARIA MACKENZIE Y 119 2007-04-19 00:00:00.000 0 heres my sql query.. SELECT primary_ID AS 'PLAYERID',FIRSTNAME AS 'FIRST',LASTNAME AS 'LAST',local,c.ptsearned as 'pointsEarned',gamingdate as 'date',roompoints = case when local='n'then (c.ptsearned) /100 when local='y'then (c.ptsearned) /100 /2else '0'endFROM cdS_PLAYER A, CDS_ACCOUNT B, CDS_STATDAY CWHEREB.primary_ID=A.player_ID ANDB.primary_ID*=C.META_ID AND C.IDTYPE='P' ANDc.STATTYPE='SLOT' andgamingdate between getdate()-547 and getdate()group BY primary_ID,FIRSTNAME,LASTNAME,local,c.ptsearned,gamingdateORDER BY primary_ID ASCthanks for anyones help on this.. any ideas or anything would be great help.. |
|
azmark30
Starting Member
11 Posts |
Posted - 2007-11-30 : 12:16:32
|
I also need this to total up the roompoints for the last 10 days.i get this playerid first last local points date roompoints208440 HARRIET ALBERTSON N 167 2006-11-28 00:00:00.000 1208440 HARRIET ALBERTSON N 235 2007-01-23 00:00:00.000 2208440 HARRIET ALBERTSON N 293 2007-03-06 00:00:00.000 2208440 HARRIET ALBERTSON N 294 2007-11-13 00:00:00.000 2208440 HARRIET ALBERTSON N 295 2007-01-16 00:00:00.000 2208440 HARRIET ALBERTSON N 305 2007-11-11 00:00:00.000 3208440 HARRIET ALBERTSON N 449 2007-11-25 00:00:00.000 4 i would like it to just add up the roompoints playerid first last roompoints208440 HARRIET ALBERTSON 16 |
 |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2007-11-30 : 12:55:56
|
Ok I was too lazy to understand your whole post but regarding:>>it does the (c.ptsearned) /100 /2 it makes it a 0 try this:(c.ptsearned) /100.00 /2.00regarding your total by person try:select playerid, first, last, sum(roompoints) as totalRoomPointsfrom <your tables>group by playerid, first, lastBe One with the OptimizerTG |
 |
|
azmark30
Starting Member
11 Posts |
Posted - 2007-11-30 : 13:28:37
|
ok the first part works.. (c.ptsearned) /100 /2.second part i need this - im guessing - order by date desc and then i need it to take the top 10 days and sum(roompoints) and theres a lot of accounts.. so i need it to do it for every account in the database..not sure if that make sense.. |
 |
|
azmark30
Starting Member
11 Posts |
Posted - 2007-11-30 : 14:17:50
|
I have a table with playerid, first , last , local, points, date, roompoints.. I need to write something that will sum(roompoints) by the first 10 dates from date..exampleplayerid first last date roompoints272012 ETHEL SWANSON 2007-06-14 00:00:00.000 627012 ETHEL SWANSON 2007-06-11 00:00:00.000 887450 JANE DOE 2007-02-12 00:00:00.000 587450 JANE DOE 2007-01-13 00:00:00.000 6this is what i want -272012 ETHEL SWANSON 1487450 JANE DOE 11and so no with the other accounts... |
 |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2007-11-30 : 17:22:52
|
is this what you are looking for?select playerid , first , last , sum(roompoints) roompointsfrom ( select playerid , first , last , roompoints from yourTable yt where date in (select top 10 date from yourtable where playerid = yt.playerid order by date desc) ) agroup by playerid , first , last Be One with the OptimizerTG |
 |
|
azmark30
Starting Member
11 Posts |
Posted - 2007-11-30 : 17:26:29
|
yup thats it.. thanks again |
 |
|
|
|
|
|
|