Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8177401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:29:59+00:00 2026-06-06T23:29:59+00:00

I have 2 tables. quiz table ================= id, q_name, code completed_quizes table ====================================================== id,

  • 0

I have 2 tables.

quiz table 
=================
id, q_name, code


completed_quizes table
======================================================
id, completion_date, user_id, quiz_code, quiz_count

I have 2 types of quizes

Table_name: quiz_names
id     q_name              code
1      grand_quiz          gra
2      normal_quiz         nor

Table_name: completed_quizes
id    completion_date         user_id      q_code   q_count
1     1340841600 (28June2012)    2          gra       0
2     1340755200(27June2012)     2          nor       3
3     1340668800(26June2012)     2          nor       2
4     1340582400(25June2012)     2          nor       1
5     1340496000(24June2012)     2          gra       0
6     1340841600 (28June2012)    3          gra       0
7     1340755200(27June2012)     3          nor       3
8     1340668800(26June2012)     3          nor       2
9     1340582400(25June2012)     3          nor       1
10    1340496000(24June2012)     3          gra       0

Rules:

1- first of all all users grand quiz will be taken.

2- based on grand quiz, if any user last quiz was grand quiz then next suggestion will be normal quiz 1.

3- based on normal quiz 1 , if any user last quiz was normal quiz 1 then next suggestion will be normal quiz 2.

4- based on normal quiz 2 , if any user last quiz was normal quiz 2 then next suggestion will be normal quiz 3.

5- if any users last quiz was normal quiz 3 then again grand quiz will be next suggestion.

P.S

Problem is that every users next suggestion is based upon his previous completed quiz. I want all users who’s what will be the next quiz?

Any advice please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:30:01+00:00Added an answer on June 6, 2026 at 11:30 pm

    You need the groupwise maximum to obtain the latest quiz performed by each user, then add 1 (using MOD to rotate back to 0 those who’ve most recently taken quiz 3). To include users who have not yet taken any quiz, you need to make an outer join with your user table:

    SELECT user_id, IFNULL((q_count+1) % 4, 0) AS next
    FROM   users LEFT JOIN (
      completed_quizes NATURAL JOIN (
        SELECT   user_id, MAX(completion_date) AS completion_date
        FROM     completed_quizes
        GROUP BY user_id
      ) AS t
    ) USING (user_id)
    

    See it on sqlfiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, theme and quiz , here is their definition: CREATE TABLE
In my database I have tables that define types for example Table: Publication Types
I have the following database design: Employee Table: Username, Name Quiz Table: QuizID, Title,
I have tables linked by FK, I query on the first table using entity
Recently I came across with the following quiz. Imagine we have this table +--------+
I have a bit of code I wrote, that echo's 3 variable (quiz name,
I have tables: Teachers and Students. We have a SpecialProjects Table where Teachers and
I have tables item and store (it's a store management system). item table has
I have about 6 tables in my MySQL database, like mysql> describe Quiz; +--------------+-------------+------+-----+---------+----------------+
Kind of stuck on a query. I have a table of quiz results which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.