[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

Need to combine 2 sql selects into one stored procedure

Asked by GordonAluminum in MS SQL Server, SQL Query Syntax

I have 2 sql selects that I would like to combine into one.  Basically one is a select for master record and the other is for a detail record.  My ultimate goal would be to list the master record and then list the detail records below it but I have no idea on how to accomplish this.  The current selects are in 2 stored procedures.

Here is the first procedure:

ALTER PROCEDURE [dbo].[Rpt_GAICustomerOrderInformationSp]
(
       @startdate    datetime = NULL
     ,@enddate     datetime = NULL
)
AS

select
      co.co_num,
      co.cust_num,
      co_line,
      coitem.ref_num,
      coitem.ref_line_suf,
      name,
      due_date,
      item.item,
      drawing_nbr,
      qty_ordered,
      uf_shippingtolerance,
      qty_shipped,
      coitem.stat
from
      co, custaddr, coitem, item
where
      co.cust_num = custaddr.cust_num and
      co.cust_seq = custaddr.cust_seq and
      co.co_num = coitem.co_num and
      coitem.item = item.item and
    due_date >= @startdate and due_date <= @enddate and       
      coitem.stat not in('F','C') and coitem.ref_type = 'J'

Here is the 2nd:

ALTER PROCEDURE [dbo].[Rpt_GAIJobInformationSp]

AS

select
      job.job,
      job.suffix,
      job.ord_num,
      job.ord_line,
      jobroute.oper_num,
      (select description from wc where wc = jobroute.wc) as wc,
      job.item,
      jobroute.qty_received,
      jobroute.qty_complete,
      jobroute.qty_scrapped,
      jobroute.qty_moved,
      start_date,
      end_date

From
      job,
      jrt_sch,
      jobroute
Where
      job.job = jrt_sch.job and
      job.suffix = jrt_sch.suffix and
      job.job = jobroute.job and
      job.suffix = jobroute.suffix and
      jrt_sch.oper_num = jobroute.oper_num
      
      
order by job.job asc, job.suffix desc, jobroute.oper_num asc

The records would be connected by co.co_num = job.ord_num and co.co_line = job.ord_line

[+][-]11/05/09 08:13 AM, ID: 25750968Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: MS SQL Server, SQL Query Syntax
Sign Up Now!
Solution Provided By: aneeshattingal
Participating Experts: 2
Solution Grade: A
 
[+][-]11/05/09 08:19 AM, ID: 25751021Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625