I'm developing an facebook application. In this app I get the friends of the user using the graph api. For example:
$facebook->api("/{$user_id}/friends?fields=id,name,gender");
This works fine, but I want to filter to get just the male, or just the female friends. I'm doing this by getting all the friends of the user and then selecting the males or females, but I want to know if there is a way to filter that at the time of the api call. Can someone help me?
Try to use FQL:
/fql?q=select uid, name, sex from user where uid in(select uid2 from friend where uid1 = me()) and sex = "female"
FB dev explorer example
Related
I want to count the total number of males and females in a powerbi report
eg.
Name Gender
std1 Female
std2 Male
std3 Female
std4 Male
std5 Male
std6 Male
The result I want is:
Female 2
Male 4
To get the results you are looking for, follow these steps:
Make a second table using the New Table button with the following code:
GenderCounts = DISTINCT(TableName[Gender])
Make a relationship from the newly create table back to the original table
Add a new column to the GenderCounts table with the following code:
Count = COUNTROWS(RELATEDTABLE(TableName))
And there you have a second table containing the counts of each gender.
For more information and other possibilities, check out a related Power BI Community forum post here and Stackoverflow questions here and here.
I have multiple VIEWs where the PERSON_VIEW to a PHONE_VIEW has a one to many relationship. In the following query, I got TOAD to correctly output the result into 1 row for each person record.
I am having a problem getting it to work with Informatica Powercenter. I copied/pasted the query to SQ SQL Query section.
Since the query takes the PHONE_NUMBER and check against the PHONE_TYPE on whether it is of type HOME, BUSINESS, or PERSONAL, it output 3 phone number columns called HOME, BUSINESS, and PERSONAL.
I created 3 new columns in the SQ Ports called HOME, BUSINESS, and PERSONAL to match the query output columns. When I validate the query, it constantly says it must match 28 ports from the SQ. When I just add 1 column and map to Exp Transformation and then to the Target, it still give this error. I counted the ports and it is 29. If I removed the phone columns, it works and the count is 28. When I add just one phone column, it gives the error.
I think I am missing a step.
Any help is appreciated.
PERSON VIEW
1 John M. Doe
PHONE VIEW
1 111-111-1111 HOME
1 222-222-2222 BUSINESS
1 333-333-3333 WORK
TOAD Result
1 John M. Doe 111-111-1111 222-222-2222 333-333-3333
Here is the QUERY (This works in TOAD)
SELECT PERSON.PERSON_ID,
PERSON.FIRST_NAME,
PERSON.MIDDLE_NAME,
PERSON.LAST_NAME,
PHONE.HOME,
PHONE.BUSINESS,
PHONE.PERSONAL,
PHONE_TYPE
FROM PERSON_VIEW PERSON
LEFT JOIN (SELECT * FROM (SELECT PERSON_ID, PHONE_TYPE,PHONE_NUMBER
FROM PHONE_VIEW)
PIVOT
(
MAX(PHONE_NUMBER)
FOR PHONE_TYPE in ('HOME' AS HOME,'PERSONAL' AS PERSONAL , 'BUSINESS' AS BUSINESS)
)
)PHONE ON PHONE.PERSON_ID = PERSON.PERSON_ID
I am not getting all results which I can see on my timeline in Checkins api and location_post fql. The results returned are very old and can't be sorted.
I have following permission
user_checkin
user_location
friend_checkin
friend_location
Here's an example of all checkins from your friends that have happened in the last 6 months (2678400 seconds in a month).
SELECT author_uid, tagged_uids, target_id, coords, timestamp FROM
checkin WHERE author_uid IN (SELECT uid2 FROM friend WHERE uid1 =
me()) and timestamp > (now() - (2678400*6))
I have a case where I need to count the number of records grouped by publishing year. I've looked at the documentation, and the net in general, but I can't find what to use.
e.g.
2013 = 100 books published
2012 = 95 books
etc..
Using Oracle SQL, this is done using:
select date_published, count(*)
from publications
group by date_published
order by date_published desc
I'm just wondering how to translate this to CFWheels.
Try this:
publications=model("publication").findAll(
select="date_published, COUNT(date_published) AS publishCount"
, group="date_published"
, order="date_published DESC" );
NB, COUNT() is a case-sensitive command in wheels.
PS, or you can do what matt says - you could even attach it to the model so you could do publications.getPubCountByYear() etc.
This is more of a comment, but because I need the formatting I'm posting it as an answer. Can't you write a query just like a regular query in ColdFusion?
<cfquery name="getCounts" datasource="myDSN">
select date_published, count(*)
from publications
group by date_published
order by date_published desc
</cfquery>
I am executing this fql query
SELECT status_id,message FROM status WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) order by rand() limit 10
the result I get is just few statuses (about 4), instead of the 10 I asked for, and they are always the same, instead of being random as I asked.
Any advice?
Thank you in advance
SELECT status_id, message
FROM status
WHERE uid IN (
SELECT uid2 LIMIT 10
FROM Friend
WHERE uid=me())
ORDER BY rand()