Click here to Skip to main content
15,309,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using classical asp. I have to tables. The first table that is called "sorutip" have tiles of every group. The second table that is called "Questions41" have questions. I want to number each group starting from 1 as in the example below.

Complete the gaps.

1- I .................. (play) football with my friends on Sundays.
2- Penguins ................................... (live) in the Antarctic.
3- Tina ................................... (walk) to school every day.
4- We ..................... (go) to bed at 10 o’clock every night.

Answer the questions

5- Did you help your mother in the kitchen yesterday?
6- Was there a science lab in your school two years ago?
7- What was the name of the last movie you went to?
8- Did you meet your friends last weekend?
9- Did you watch TV yesterday?
10- Was there an English class yesterday?

Put the sentences into the correct order

11- I / wear / usually / jeans / to school
12- late / he / for school / often / is
13- Mum / for breakfast / always / toast / makes
14- my parents / go to / never / the cinema

I was able to get the questions and group them, but I could not manage to number each group separately from the beginning.

What I have tried:

My code is here ...
Set oRS= conn.Execute("SELECT  DISTINCT(questions41.tid),sorutip.tid,sorutip.title, questions41.question FROM questions41 LEFT JOIN sorutip ON questions41.tid=sorutip.tid  GROUP BY questions41.tid,sorutip.tid,sorutip.title,questions41.question") 

Dim title2, previousGroupName
title2 = ""
previousGroupName = ""

Do Until oRS.EOF
    title2 = oRS("title")
    question= oRS("question")
    If title2<>previousGroupName Then
    End If


Response.Write(" "&  number &"- " & question & "<br />")
    previousGroupName = title2

Updated 24-Dec-21 22:22pm

1 solution

A GROUP BY clause doesn't work like that: each term you add yo teh GROUP BY list increases the number of rows returned.

Have a look here: SQL GROUP By and the "Column 'name' is invalid in the select list because..." error[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900