A few followup questions:
I have successfully generate 9 categories tables and also successfully combined them into 1 table(see as follow):
DROP TABLE IF EXISTS user_profiles;
CREATE TABLE user_profiles (
SELECT temp_gender.user_id, temp_gender.gender, temp_age.age, temp_education.education...
Sorry for late reply. Had the flu and wasn't feeling too well to reply...First of all, thanks for all your answers and so soon. Unfortunately, the queries couldn't be successfully applied. Instead I use the suggestion provided by JarlH as follow
SELECT
user_profiles.user_id,
MAX(CASE WHEN...
Well the first part of the statement works, the second part doesn't...Maybe something I left out. if user decide not to fill in, it doesn't get recorded So there is no
user_id gender
"13397","0"
this row doesn't exist in table...but I do want to be retrieved when I query for the whole list
Hi guys,
I am having problem to add additional condition(s) to my SQL statement in PHP
This is the following SQL statement:
SELECT EXTRACT(YEAR FROM users.date) AS Year,
SUM(CASE WHEN table_gender.profile_id = 1 THEN 1 ELSE 0 END) AS "Men",
SUM(CASE WHEN table_gender.profile_id =...
Hi Guys,
thanks for your input, really saved me there, the problem of uniqueness has been solved. But still I do have a question...
Is there any possibility to rewrite the following SQL statement.
SUM(CASE WHEN ... AND ... AND ... AND ... THEN 1 ELSE 0 END)
So I don't need to write lines...
the table is self joined, the table consist of 2 columns, both are multi-key. the first column consist of the user and = multi-rows, the second column consist the different categories belonging to the particular user. by self joining it, I can categorise it. Like querying male or female from...
Hi Guys,
Thanks for all your suggestions. This is just a part of the whole query so far.
SELECT EXTRACT(YEAR FROM users.date) AS Year,
COUNT(DISTINCT CASE WHEN table_gender.profile_id = 1 THEN table_gender.user_id END) AS "Men",
COUNT(DISTINCT CASE WHEN table_gender.profile_id = 1 AND...
Thank you all for your reply, and indeed I understand what happened in the queries you all mentioned.
My next question apply to the number of rows I have to insert for my query at the moment:
SELECT EXTRACT(YEAR FROM users.date) AS Year,
COUNT(DISTINCT CASE WHEN table_gender.profile_id = 1...
Could you elaborate what you mentioned? Quite confused...
Maybe because I am a n00b.
But because the second column of my table consist of id´s of several different items... I would like to divide the gender, ages etc in different columns
IF I would do the following, the result would be stack...
I know this is lame
but how would you rewrite the following query if you would want to add a third column into it?
SELECT EXTRACT(YEAR FROM users.date) AS Year, COUNT(DISTINCT user_profile.user_id) AS Men
FROM users INNER JOIN user_profile ON users.id = table_profile.user_id
WHERE...
thanks for your help. It was very helpful. I would like to post a follow-up....
I am doing this as follow, but can I somehow simplify this:
SELECT COALESCE(COUNT(DISTINCT table_gender.user_id), '0') AS Users -- Men 2008
FROM users INNER JOIN user_profile AS table_gender ON users.id =...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.