Filter by Wildcard

Forum for users that want to write their own custom queries against the PT database either via the Structured Query Language (SQL) or using the PT3 custom stats/reports interface.

Moderator: Moderators

Filter by Wildcard

Postby Telepee » Tue Feb 03, 2009 3:40 pm

A group of us are (anonymously) Benchmarking against one another - I've created a number of reports to show just our stats.

The filter I am using to restrict player name is as follows:

#Player#='Player01' OR #Player#='Player02' OR #Player#='Player03' OR #Player#='Player04' OR #Player#='Player05' OR #Player#='Player06' OR #Player#='Player07' OR #Player#='Player08' OR #Player#='Player09' OR #Player#='Player10' OR #Player#='Player11' OR #Player#='Player12' OR #Player#='Player14'

The players involved are growing and changing - I have to have the filter in each report, so every change I have to make in every report. Not too much hassle at the moment, but I expect the number of reports I have to grow dramatically as we get into this. I would much prefer to filter with a wildcard character so that I can forget about it - I'd like to replace the code above with something like....

#Player#='Player*'

The code above does not work, but hopefully you can see from it what I'm trying to do - is it possible for me to add a filter using a wildcard?

Thanks
Telepee
 
Posts: 23
Joined: Fri May 16, 2008 10:58 am

Re: Filter by Wildcard

Postby WhiteRider » Wed Feb 04, 2009 6:13 am

I just found this out last week - you can filter like this:

#Player# LIKE 'Player%'

..which means that the player name is "Player" followed by any other characters.
If you want to do anything more specific, have a look at this page.
WhiteRider
Moderator
 
Posts: 54017
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Filter by Wildcard

Postby Telepee » Fri Feb 06, 2009 6:57 pm

That works great - ty :)
Telepee
 
Posts: 23
Joined: Fri May 16, 2008 10:58 am

Re: Filter by Wildcard

Postby Telepee » Fri Feb 13, 2009 7:30 am

I'm trying to run this report:
Image

The objective is to show cumulative stats for the selected players. The result however seems to GROUP BY the selected players whilst what I'm really trying to do is show the stats WHERE the player is one of ours.

Any guidance would be appreciated.
Telepee
 
Posts: 23
Joined: Fri May 16, 2008 10:58 am

Re: Filter by Wildcard

Postby kraada » Fri Feb 13, 2009 11:43 am

Well, one point is you can just use #Player# LIKE 'Player%' and get it all in one line.

I think if you use the Player stat it's going to always group on that player though; it uses the str_player_name column which has group by checked. You could duplicate that column and create a new column str_player_name_no_group (or whatever you'd prefer to call it) that isn't grouped by, then run reports using that one and it should lump everything together for you.
kraada
Moderator
 
Posts: 54431
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Filter by Wildcard

Postby Telepee » Fri Feb 13, 2009 11:54 am

kraada wrote:Well, one point is you can just use #Player# LIKE 'Player%' and get it all in one line.


The reason I've done it that way is that there's a player in the database called Player_007 who is not a part of the group.

kraada wrote:I think if you use the Player stat it's going to always group on that player though; it uses the str_player_name column which has group by checked. You could duplicate that column and create a new column str_player_name_no_group (or whatever you'd prefer to call it) that isn't grouped by, then run reports using that one and it should lump everything together for you.


ty - I'll give that a try this weekend.
Telepee
 
Posts: 23
Joined: Fri May 16, 2008 10:58 am

Re: Filter by Wildcard

Postby kraada » Fri Feb 13, 2009 11:58 am

% reads to the end of the string, not just the next character.

Player% would match: Player1, Player70, Player_x357, etc.
kraada
Moderator
 
Posts: 54431
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Filter by Wildcard

Postby Telepee » Fri Feb 13, 2009 12:04 pm

kraada wrote:% reads to the end of the string, not just the next character.

Player% would match: Player1, Player70, Player_x357, etc.


If I use:
#Player# LIKE 'Player%'
instead of:
#Player# LIKE 'Player0%' OR #Player# LIKE 'Player1%'
then it will include Player_007. I want to exclude Player_007 and just include Player01, Player02, Player03 ... Player19
Telepee
 
Posts: 23
Joined: Fri May 16, 2008 10:58 am

Re: Filter by Wildcard

Postby kraada » Fri Feb 13, 2009 1:17 pm

Ah, I see. And not(#Player# LIKE 'Player_%') would work too but since you only have 19 players I guess it's the same number of queries.
kraada
Moderator
 
Posts: 54431
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Filter by Wildcard

Postby Telepee » Sat Feb 14, 2009 8:51 am

kraada wrote: You could duplicate that column and create a new column str_player_name_no_group (or whatever you'd prefer to call it) that isn't grouped by, then run reports using that one and it should lump everything together for you.


I'm struggling a bit with this - getting the error: "player.player_name must appear in the GROUP BY clause or be used in an aggregate function"

Image

Image
Telepee
 
Posts: 23
Joined: Fri May 16, 2008 10:58 am

Next

Return to Custom Stats, Reports, and SQL [Read Only]

Who is online

Users browsing this forum: No registered users and 18 guests

cron