Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. vengelus82

    lost in querying

    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...
  2. vengelus82

    lost in querying

    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...
  3. vengelus82

    lost in querying

    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
  4. vengelus82

    lost in querying

    Dear all, this is my following problem: 28035,"104" 28035,"31" 28035,"39" 28035,"75" 28035,"2" 28035,"86" 28035,"44" 28035,"84" 28035,"98" 476,"1" 476,"76" 476,"40" 476,"31" 476,"102" 476,"93" 476,"53" 476,"83" 476,"96" 6697,"76" 6697,"1" 6697,"41" 6697,"32" 6697,"102" 6697,"94" 6697,"83"...
  5. vengelus82

    sum case when

    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 =...
  6. vengelus82

    Rescue this newbie

    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...
  7. vengelus82

    Rescue this newbie

    Well, it is quicker, but count every row up instead of counting any unique users
  8. vengelus82

    Rescue this newbie

    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...
  9. vengelus82

    Rescue this newbie

    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...
  10. vengelus82

    Rescue this newbie

    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...
  11. vengelus82

    Rescue this newbie

    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...
  12. vengelus82

    Rescue this newbie

    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...
  13. vengelus82

    Rescue this newbie

    Indeed, it is DATETIME and it is exactly what I needed.
  14. vengelus82

    Rescue this newbie

    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 =...
  15. vengelus82

    Rescue this newbie

    Hi Guys, I am using SQL to categorize certain data. 28035 104 28035 30 28035 39 28035 75 28035 2 28035 86 28035 44 28035 84 28035 98 476 1 476 76 476 40 476 30 476 102 476 93 476 53 476 83 476 96 6697 76 6697 1 6697 41 6697 30 6697 102 6697 94 6697 83 6697 96 I want to select cells from the...

Part and Inventory Search

Back
Top