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 |
abc123
Starting Member
47 Posts |
Posted - 2009-01-30 : 03:18:07
|
I have 2 tables as followUserId Name1 abc1 xyz1 pqr2 wxy3 defLID_statusID LID Status Date ModifiedBy1 1 open 1/1/2009 abc2 1 submit 1/2/2009 xyz3 1 closed 1/3/2009 pqr4 2 open 1/1/2009 abc5 2 submit 1/2/2009 xyz6 2 submit 1/3/2009 xyz7 2 progess 1/4/2009 def8 3 open 1/5/2009 abc9 3 submit 1/6/2009 xyz10 3 closed 1/7/2009 pqrI want the count of LID for each status whose ID = 1 in User Tableo/p should be as followcount_LID Status3 open3 submit2 closed |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-30 : 03:30:54
|
[code]SELECT l.Status,COUNT(LID)FROm Users uINNER JOIN LID_Status lON l.Modified_By=u.NameWHERE u.ID=1GROUP BY l.Status[/code] |
|
|
abc123
Starting Member
47 Posts |
Posted - 2009-01-30 : 03:49:27
|
but this query is returning 4 for Submit status..it should be 3 ..In table there are 2 records for 2 LID |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-01-30 : 03:56:57
|
COUNT(DISTINCT LID) E 12°55'05.63"N 56°04'39.26" |
|
|
abc123
Starting Member
47 Posts |
Posted - 2009-01-30 : 04:06:23
|
Thanks for ur help |
|
|
|
|
|