SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Query for Selecting Two Tables


Query for Selecting Two Tables

Poll
Query for Selecting Two Tables

0% - 0 votes ProjectTable:
0% 0 votes
0% - 0 votes
0% 0 votes
0% - 0 votes ID ProjectID ProjectName
0% 0 votes
0% - 0 votes
0% 0 votes
0% - 0 votes 1 PRO14 Demo
0% 0 votes
0% - 0 votes 2 PRO15 Test
0% 0 votes
0% - 0 votes
0% 0 votes
0% - 0 votes Task Table:
0% 0 votes
0% - 0 votes
0% 0 votes
0% - 0 votes ID ProjectID TaskID TakName
0% 0 votes
0% - 0 votes
0% 0 votes
0% - 0 votes 1 PRO14 12 module
0% 0 votes
0% - 0 votes 2 PRO14 13 code
0% 0 votes
0% - 0 votes 3 PRO15 14 Design
0% 0 votes
0% - 0 votes
0% 0 votes
Member votes: 0, Guest votes: 0. You don't have permission to vote in this poll
Author
Message
sidharthgs6
sidharthgs6
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 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
Sean Lange
Sean Lange
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: General Forum Members
Points: 63570 Visits: 17966

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 Modens 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)
Kingston Dhasian
Kingston Dhasian
SSCertifiable
SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)

Group: General Forum Members
Points: 6080 Visits: 5280
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/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search