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 |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2008-01-10 : 06:27:20
|
| select lastname,picture, count(lastname) from images where date>='2007-12-11' and date<='2007-12-11 23:59' group by platehow can i get the pictures included but still group by platei basically want to be able to query all plates that have only 1 lastname in the criteria and not more then that. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-10 : 06:30:40
|
| Try thisSelect t1.* from images t1 inner join (select plate,count(lastname) as counting from images group by plate having count(lastname)=1) as t2on t1.plate=t2.plateMadhivananFailing to plan is Planning to fail |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2008-01-10 : 06:38:11
|
| but i need the where criteria in both endsthere's no way to do a groupby but include another field |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-10 : 06:46:41
|
| what is pk of table? |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2008-01-10 : 06:51:58
|
| id |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-10 : 06:54:24
|
| Try this:-select t1.lastname,t1.picture,t2.lastnamecount from images t1inner join (select plate,count(lastname) as 'lastnamecount' from images where date>='2007-12-11' and date<='2007-12-11 23:59' group by plate)t2on t2.plate=t1.platewhere t1.date>='2007-12-11' and t1.date<='2007-12-11 23:59' |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-10 : 07:26:48
|
quote: Originally posted by esthera but i need the where criteria in both endsthere's no way to do a groupby but include another field
Well. If that is the case, dont you really know how to do that? MadhivananFailing to plan is Planning to fail |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
|
|
|