Advertisement

07.03.2008 at 05:39PM PDT, ID: 23538499
[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!

7.4

inner join nesting Sql script

Asked by lacroix_al in SQL Query Syntax, MS SQL Server, SQL Server 2005

Tags: ,

Hi,
I would like to concatinate the following three scripts in to one script.
What I need is to have for each name and address returned from the frirst script all the members associated to that member from the second script and all the charges associated the the name from the first script.
What I think I have to do is multipul inner joins but this is above my knowelege of SQL.
here are the scripts
Script 1
===============================
Select
      t.hmyperson
      ,t.sfirstname + ' ' +t.slastname Tname
      ,t.saddr1
      ,t.scity
      ,t.sstate
      ,t.szipcode

FROM   tenant t

ORDER by t.hmyperson
=========================================
Script 2
=========================================
Select  
      T.hMyPerson
      ,ltrim(IsNull(F.sFIrstName + ' ', '') + IsNull(F.sLastName, '')) MemberName
From       property p
      inner join tenant t on (p.hmy = t.hproperty)
      Inner Join H8Family F on F.hTenant = T.hMyPerson
      And F.hSum = dbo.fh8_PRH_GetLatest58(T.hMyPerson, '07/01/08', '123456789ABCDEF')
Where
      F.iAge > 18
      AND F.sRelation <> 'H'
      
order by t.hmyperson
=====================================
Script 3
=====================================
Select
      t.hmyperson
      ,convert(varchar,tr.sDateOccurred,101) as dateocc
      ,'RENT' chargetype
      ,tr.sTotalAmount as Charge
      , tr.samountpaid as paid
      ,sum(tr.sTotalAmount - tr.samountpaid)unpaid

FROM   Acct a, Trans tr
                     left outer join acct ar on tr.hAccrualAcct = ar.hMy
                     left outer join chargtyp ct on tr.hRetentionAcct = ct.hMy, tenant t, tenstatus ts, property p
                  

WHERE  
      tr.iType = 7
         AND tr.hOffsetAcct = a.hMy
         and tr.hPerson = t.hMyPerson
         AND tr.hProp = p.hMy
         and t.iStatus = ts.istatus
         and tr.bopen=-1
         and ts.status = 'current'

group by t.hmyperson, t.scode, t.slastname,t.sfirstname,tr.hmy,t.sunitcode,
    ts.status,tr.sdateoccurred,tr.upostdate,ct.scode,a.scode,ar.scode,tr.stotalamount,tr.snotes,p.scode,t.sunitcode,t.putcode,tr.samountpaid,t.saddr1,t.scity,t.sstate, t.szipcode
Having
      sum(tr.sTotalAmount) >= '0'
ORDER by t.hmyperson, tr.sDateOccurred, p.scode

Thank you for any help you can give me
Al


      Start Free Trial
[+][-]07.03.2008 at 06:00PM PDT, ID: 21930397

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]07.03.2008 at 06:04PM PDT, ID: 21930411

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]07.03.2008 at 07:57PM PDT, ID: 21930767

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]07.04.2008 at 06:42AM PDT, ID: 21933056

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.04.2008 at 09:04AM PDT, ID: 21933759

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]07.04.2008 at 10:15AM PDT, ID: 21934041

View this solution now by starting your 7-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: SQL Query Syntax, MS SQL Server, SQL Server 2005
Tags: Microsoft, SQL
Sign Up Now!
Solution Provided By: OnALearningCurve
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.09.2008 at 01:27AM PDT, ID: 21961485

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628