15,792,352 members
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.

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 ...
<pre><%
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
Response.Write("<p>")
Response.Write(oRS("title"))
Response.Write("</p>")
End If

number=number+1

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

oRS.MoveNext
Loop
oRS.Close
%>```
Posted
Updated 24-Dec-21 23:22pm

## Solution 1

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[^]