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)
 Outputting results from a JOIN and GROUP BY string

Author  Topic 

Fflyer
Starting Member

8 Posts

Posted - 2001-09-07 : 15:54:42
Situation: 1 Member visits several restaurants. Each restaurant has a code. One table has the member id and the code number of the restaurant visited. The other table has the code number of the restaurant AND the description of the restaurant. I have the tables joined at the code. The results I am seeking is a grouping on the member first, then the restaurant description. In other words, I only want to see that restaurant name once in the "report." In a simple SELECT query it is easily understood how you walk through each record and either Response.Write it or not, but in this case, how do I output the results when there is some aggregation going on?

The code looks like this: (by the way AAnumber is retrieved from a previous form element)

strSQL = "SELECT AG_TWEN_TEMP1.ACCT_NR, AG_TWE_PROM.BRND_DESC"
strSQL = strSQL & " FROM AG_TWEN_TEMP1 INNER JOIN AG_TWE_PROM ON AG_TWEN_TEMP1.BRAND = AG_TWE_PROM.BRAND"
strSQL = strSQL & " GROUP BY AG_TWEN_TEMP1.ACCT_NR, AG_TWE_PROM.BRND_DESC"
strSQL = strSQL & " HAVING AG_TWEN_TEMP1.ACCT_NR = '"& AAnumber &"'"

Thank you!

Chad

   

- Advertisement -