Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

query 2nd table based on results of 1st query

Posted on 2011-09-20
2
219 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

Suggested Solutions

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 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