Solved

query 2nd table based on results of 1st query

Posted on 2011-09-20
2
220 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
[X]
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
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:Huseyin KAHRAMAN
ID: 36568324
please give a sample data from both tables and the result that you are looking for...
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sql Permission 6 74
Get row count of current SQL query 8 64
Need help debbuging stored procedure 21 48
Update one rows based on previous row 5 30
If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
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…

733 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