Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Query for Selecting Two Tables Expand / Collapse
Query for Selecting Two Tables
Poll ResultsVotes
ProjectTable:
0%
0
0%
0
ID ProjectID ProjectName
0%
0
0%
0
1 PRO14 Demo
0%
0
2 PRO15 Test
0%
0
0%
0
Task Table:
0%
0
0%
0
ID ProjectID TaskID TakName
0%
0
0%
0
1 PRO14 12 module
0%
0
2 PRO14 13 code
0%
0
3 PRO15 14 Design
0%
0
0%
0
Member Votes: 0, Anonymous Votes: 0. You don't have permission to vote within this poll.
Author
Message
Posted Monday, December 3, 2012 7:10 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, April 29, 2013 9:22 PM
Points: 6, Visits: 14
ProjectTable:

ID ProjectID ProjectName

1 PRO14 Demo
2 PRO15 Test

Task Table:

ID ProjectID TaskID TakName

1 PRO14 12 module
2 PRO14 13 code
3 PRO15 14 Design

I want to sql query for

ProjectName TaskCount

Demo 2
Test 1
Post #1391928
Posted Monday, December 3, 2012 7:36 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:12 PM
Points: 13,441, Visits: 12,303
select tableA.Col, COUNT(Tableb.ID) as MyCount
from tableA a
join Tableb b on a.ID = b.ID
group by table.Col



_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1391943
Posted Monday, December 3, 2012 7:38 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, September 12, 2014 4:32 AM
Points: 2,652, Visits: 4,731
You can look up INNER JOIN and GROUP BY Google or Books Online

Using these two concepts, you can get the desired result
If you face any further issues get back to us with what you have tried,we would be happy to help you out..



Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1391947
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse