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 |
|
cutepraba
Yak Posting Veteran
53 Posts |
Posted - 2008-07-26 : 08:09:18
|
| I have two tablessffoldersfolderid foldername userid1 Codes 12 Database 13 Goldscribe 14 Bomb 15 Links 16 email 17 Fun 18 personal 1SFDATAfileid folderid userid file1 1 1 452152 2 1 452163 1 1 452174 4 1 452185 3 1 452196 6 1 452107 7 1 452118 8 1 452129 8 1 45213Now i need to display the distinct folders of user 1, and count of files.Folderid foldername filecount1 Codes 22 dabase 0...........I have tried with the follwoing code, can anyone please help me.SELECT DISTINCT f.folderid, f.foldername, (select count(*) from u.userid where u.userid=f.userid and f.folderid=u.folderid)FROM sffolders AS f, sfdata AS u;____________Praba |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-07-26 : 08:55:00
|
| select f.folderid, f.foldername, count(*) as [filecount]from [sffolders] finner join [sfdata] d on d.folderid = f.folderid and d.userid = f.useridwhere d.userid = 1group by f.folderid, f.foldernameBe One with the OptimizerTG |
 |
|
|
cutepraba
Yak Posting Veteran
53 Posts |
Posted - 2008-07-26 : 09:11:11
|
| Wow, super.I must learn very hard.Thank you.____________Praba |
 |
|
|
|
|
|