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 |
|
bangaramnu
Starting Member
2 Posts |
Posted - 2009-09-15 : 06:25:47
|
| hi,in my database there are 2 tables namely photos and photosets.the columns of PhotoSet table are: Photosetid[PrimaryKey],Name,desc, etc.the columns of Photos table are : PhotoId[Primary Key], PhotoSetid[Foreign Key],etc.now, i want a result like below:The PhotoSetName and the total number of images of that PhotoSetName in Photos table, i.e. Name[From PhotosetId], Total Images[Count(PhotoSetId) of Photos table]how can I get the about result ?help me pls.thanks in advance |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-09-15 : 06:31:57
|
| select ps.name,count(distinct photosetid) as totalimagesfrom photoset psinner join photos p on p.photosetid = ps.phototsetidgroup by ps.name |
 |
|
|
bangaramnu
Starting Member
2 Posts |
Posted - 2009-09-15 : 06:40:45
|
quote: Originally posted by bklr select ps.name,count(distinct photosetid) as totalimagesfrom photoset psinner join photos p on p.photosetid = ps.phototsetidgroup by ps.name
hi BKLR, Thankyou for your responce.your query is not working when i want specific ps names depending upon some criteria.i.e. if I want the ps names of photoset id=3, then it also it displays all the photoset names. i.e.select ps.name,count(distinct photosetid) as totalimagesfrom photoset psinner join photos p on p.photosetid = 3group by ps.namethe above query results all the ps names not the specific ps names.I want like that pls. |
 |
|
|
|
|
|
|
|