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.
| Author |
Topic |
|
alxtech
Yak Posting Veteran
66 Posts |
Posted - 2009-07-23 : 10:21:09
|
| hello forum,Having this table:userID firstname department status==============================================1 alex production master2 mary sales admin3 john production admin4 lili clerk master5 keith maintenance master6 willi clerk admin7 david sales masterI need a sql statement to extract and display all users group by department, the output in html will look like this:DEPARTMENT:PRODUCTIONUSERID | NAME | STATUS-------------------------1 alex master3 john admin****************************DEPARTMENT:SALESUSERID | NAME | STATUS-------------------------2 mary admin7 david master****************************DEPARTMENT:CLERKUSERID | NAME | STATUS-------------------------4 lili master6 willi admin****************************DEPARTMENT:MAINTENANCEUSERID | NAME | STATUS-------------------------5 keith masterany suggestions will be appreciated.thank you. |
|
|
alxtech
Yak Posting Veteran
66 Posts |
Posted - 2009-07-23 : 11:08:09
|
| I figured it out:Solution: create to statements.first: strSQLStatement = "SELECT distinct department FROM table" then: inside first statement do this.strSQLStatement = "SELECT * FROM table where department='" & recordset("department") & "'" finally, populate table, looping through department value. |
 |
|
|
|
|
|