Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 506959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:45:17+00:00 2026-05-13T06:45:17+00:00

How can i join these two queries SELECT GLMA_COMP_CODE COMP, GLMA_ACCT_CODE ACCOUNT_NO, GLMA_DEPT_NO DEPT,

  • 0

How can i join these two queries

SELECT
GLMA_COMP_CODE COMP,
GLMA_ACCT_CODE ACCOUNT_NO,
GLMA_DEPT_NO DEPT,
GLMA_ACCT_NAME ACCOUNT_NAME
FROM GLAS_GL_MASTERS 
WHERE GLMA_COMP_CODE = @COMP_CODE
AND GLMA_YEAR = CONVERT(NUMERIC(8, 2), DATEPART(YYYY, @DATE_FROM))
AND GLMA_ACCT_CODE BETWEEN ISNULL(@ACCT_CODE_FROM, GLMA_ACCT_CODE) AND 
ISNULL(@ACCT_CODE_TO, GLMA_ACCT_CODE)
ORDER BY GLMA_ACCT_CODE 

SELECT
GLTR_COMP_CODE,
GLTR_DEPT_NO,
GLTR_ACCT_CODE,
CAST(GLTR_PSTNG_TYPE AS VARCHAR) + CAST(GLTR_PSTNG_NO AS VARCHAR) REF_NO,
CAST(GLTR_DOC_CODE AS VARCHAR) + CAST(GLTR_OUR_DOC_NO AS VARCHAR) DOC_NO,
GLTR_DOC_DATE DOC_DATE,
GLTR_DOC_NARR NARRATIVE,
GLTR_PSTNG_DATE,

CASE SIGN(GLTR_TRAN_AMT) 
WHEN + 1 THEN GLTR_TRAN_AMT 
ELSE 0 
END DEBIT,

CASE SIGN(GLTR_TRAN_AMT) 
WHEN - 1 THEN GLTR_TRAN_AMT 
ELSE 0 
END CREDIT,
GLTR_TRAN_AMT AMOUNT,
GLTR_FC_CODE FC_CODE,
GLTR_FC_AMT FC_AMOUNT
FROM GLAS_GL_TRANSACTIONS 
WHERE GLTR_PSTNG_DATE BETWEEN ISNULL(@DATE_FROM, GLTR_PSTNG_DATE) AND ISNULL(@DATE_TO, GLTR_PSTNG_DATE)
ORDER BY GLTR_ACCT_CODE,
GLTR_PSTNG_DATE,
GLTR_DOC_CODE,
GLTR_OUR_DOC_NO
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:45:18+00:00Added an answer on May 13, 2026 at 6:45 am

    From what’s provided, here goes:

      SELECT t.gltr_comp_code,
             t.gltr_acct_code,
             t.gltr_dept_no,
             m.glma_acct_name
             CAST(t.gltr_pstng_type AS VARCHAR) + CAST(t.gltr_pstng_no AS VARCHAR) REF_NO,
             CAST(t.gltr_doc_code AS VARCHAR) + CAST(t.gltr_our_doc_no AS VARCHAR) DOC_NO,
             t.gltr_doc_date DOC_DATE,
             t.gltr_doc_narr NARRATIVE,
             t.gltr_pstng_date,
             CASE SIGN(t.gltr_tran_amt) WHEN + 1 THEN t.gltr_tran_amt ELSE 0 END DEBIT,
             CASE SIGN(t.gltr_tran_amt) WHEN - 1 THEN t.gltr_tran_amt ELSE 0 END CREDIT,
             t.gltr_tran_amt AMOUNT,
             t.gltr_fc_code FC_CODE,
             t.gltr_fc_amt FC_AMOUNT
        FROM GLAS_GL_TRANSACTIONS t
        JOIN GLAS_GL_MASTERS m ON m.glma_comp_code = t.gltr_comp_code
                              AND m.glma_acct_code = t.gltr_acct_code
                              AND m.glma_dept_no = t.glma_dept_no
       WHERE t.gltr_pstng_date BETWEEN COALESCE(@DATE_FROM, t.gltr_pstng_date) AND COALESCE(@DATE_TO, t.gltr_pstng_date)
         AND m.glma_comp_code = @COMP_CODE
         AND m.glma_year = CONVERT(NUMERIC(8, 2), DATEPART(YYYY, @DATE_FROM))
         AND m.glma_acct_code BETWEEN COALESCE(@ACCT_CODE_FROM, t.glma_acct_code) AND COALESCE(@ACCT_CODE_TO, t.glma_acct_code)
    ORDER BY t.gltr_acct_code, t.gltr_pstng_date, t.gltr_doc_code, t.gltr_our_doc_no
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 274k
  • Answers 274k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use the basic ActiveRecord find method to do… May 13, 2026 at 2:25 pm
  • Editorial Team
    Editorial Team added an answer You have to update each row by itself, there is… May 13, 2026 at 2:25 pm
  • Editorial Team
    Editorial Team added an answer Every element ID must be unique. An ID points to… May 13, 2026 at 2:25 pm

Related Questions

How can i join these two queries (Query1-Query2) Query1: declare @date1 datetime,@date2 datetime ,
I've got these two queries: SELECT SELECT NamesRecord.NameID, NamesRecord.FulfillmentAddressID NameFulfillmentAddressID, ContractRecord.FulfillmentAddressID, ContractRecord.BillingAddressId FROM Magnet.dbo.ContractRecord
I have two tables: Application applicationid (int) applicationname (varchar) isavailable (bit) and Holidays applicationid
I have two database tables with the following structure: actions: action_id int(11) primary key
I'm looking for a best practice advice how to speed up queries and at

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.