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 8450989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:07:05+00:00 2026-06-10T11:07:05+00:00

I have a database table like the one mentioned below. id | lecture |

  • 0

I have a database table like the one mentioned below.

id    | lecture            | subject_id | date       | is_deleted
------|--------------------|------------|------------|-----------
 1    | Introduction       | 1          | 2012-08-10 | 0   
 2    | Structure          | 2          | 2012-08-15 | 1   
 3    | Introduction       | 2          | 2012-08-12 | 0   
 4    | Functions          | 1          | 2012-08-14 | 1   
 5    | Material           | 2          | 2012-08-18 | 0   
 6    | Requirements       | 1          | 2012-08-16 | 0   
 7    | Analysis           | 1          | 2012-08-11 | 0

I need to make a view out of this table (Lecture), which will display a row no. (flow no.) for each subject ordered by date, removing is_deleted = 1 rows. Simply, making a flow no. for each lecture in a particular subject ordered by date only with not deleted lectures. So, the view made by above data will look like the following.

flow_no | id   | date       | lecture            | subject_id 
--------|------|------------|--------------------|------------
 1      | 1    | 2012-08-10 | Introduction       | 1          
 2      | 7    | 2012-08-11 | Analysis           | 1          
 3      | 6    | 2012-08-16 | Requirements       | 1          
 1      | 3    | 2012-08-12 | Introduction       | 2          
 2      | 5    | 2012-08-18 | Material           | 2          

I tried to do this in several ways and everything failed. It’s highly appreciated if someone could help me to resolve this. (mysql)

  • 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-10T11:07:07+00:00Added an answer on June 10, 2026 at 11:07 am

    I found the answer by the support of another online forum’s member. The following will give the exact result required. If there is any same Lecture.date rows it generates flow_no in Lecture.id order for those rows.

    SELECT id, lecture, Lecture.subject_id, date, c,
     (SELECT COUNT(subject_id) + 1 FROM Lecture AS l
      WHERE l.subject_id = Lecture.subject_id
      AND (l.date < Lecture.date OR (l.date = Lecture.date AND l.id < Lecture.id))
      AND is_deleted != 1
     ) AS flow_no
    FROM Lecture
    INNER JOIN
    (
     SELECT subject_id, COUNT(subject_id) AS c
     FROM Lecture
     WHERE is_deleted != 1
     GROUP BY subject_id
    ) AS counts
    ON Lecture.subject_id = counts.subject_id
    WHERE is_deleted != 1
    ORDER BY subject_id, date;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysql database with a table structure like below : Table Name
I have one large database table of request data, much like Apache request logs,
i have database table like this +-------+--------------+----------+ | id | ip | date |
that my problem: I have database table like that: id (AI) market_id 1 6
Say I have a database table like the following: FileID | FileName | FileSize
Let's say you have a database with a single table like... --------------------------------------------- | Name
I always forget how to do things like this. I have a database table
I have a MySQL database table called Participant that looks something like this: (idParticipant)
I have some code to update a database table that looks like try {
I have a question. My database table is something like this: | ID |

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.