Solved

query 2nd table based on results of 1st query

Posted on 2011-09-20
2
218 Views
Last Modified: 2012-05-12
table 1 --- master1   table2 --- custinput1

Based on the count of masterid I get from custinput1, I want to know how many posibilities are in master1.  Customer submits input file, which loads table custinput1.  The first query tells me how many records are linked to masterid in  custinput1.  I need to then take the masterid from the custinput1 file and compare how many more records are available in the master1 table.

This query tells me how many records are linked in custinput1:

select count(distinct masterid) from custinput1
  where exampleid = '3323'  and numberoflinked >0

Now I want to see how many are in master1. I'm trying...but it doesn't work., I get 0

select count (numberoflinked) from master1 where masterid in
(select count(distinct masterid) from custinput1
  where exampleid = '3323'  and numberoflinked >0)
0
Comment
Question by:abgail
2 Comments
 
LVL 11

Accepted Solution

by:
rajvja earned 500 total points
ID: 36568213
Try this

select count (numberoflinked) from master1 where masterid in
(select distinct masterid from custinput1
  where exampleid = '3323'  and numberoflinked >0)
 
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36568324
please give a sample data from both tables and the result that you are looking for...
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question