Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Recordset Paging By Inital Letter(s)

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-02 : 08:10:31
Robert writes "I have set up a webpage that displays a table grouped by the initial letter of the name.

What I have is a query to generate the heading tabs

SELECT DISTINCT left(Agency_Name,1) as FirstLetter, Count(*) as Number
FROM tblAgencys
WHERE Live=Yes
GROUP BY left(Agency_Name,1)

However, this results in a unbalanced number of records on any one page, What I would like to do is on all the entries where there would be more than X (where X=50 for now) entries,
then drop that Inital Letter and use the first two letters.

for example if the first query returned

a,10
b,1
c,100
e,50
h,4
s,500
y,1


i would like

a,10
b,1
ca,10
cc,10
cf,10
cz,70
e,50
h,4
sa,200
sb,200
sc,100
y,1


also if possible (but optional) repeat to split cz,sa,sb,sc further.


Many Thanks,
Oh and if possible SQL7 Please
"
   

- Advertisement -