Modifying SQL query

Mitchell, Jennifer 1 Reputation point

I have no experience with SQL however I have a pre-exisiting query and I want to add a filter that states in-service as Y and dates between 21-Aug-21 through -11-Sep-21

See below query and screenshot

,t5 AS
(Select/+parallel(8)/ ACCT_ID,SA_ID, char_type_cd Deposit_Char,char_val Deposit_Char_Value, Quoted_Deposit_Amount,Deposit_on_Hand,START_DT Quote_Date,
(case when Deposit_on_Hand is null then Quoted_Deposit_Amount else Quoted_Deposit_Amount-Deposit_on_Hand end) Deposit_Amt_Unpaid
From (
SELECT /+parallel(8)/
SA.ACCT_ID,SA.SA_ID,sc.char_type_cd,sc.char_val, sa.tot_to_bill_amt Quoted_Deposit_Amount,sa.START_DT,
row_number() over(partition by SA.ACCT_ID order by sa.START_DT desc) Deposit_rnk,
(sum(ft.tot_amt)*(-1)) Deposit_on_Hand
from cisadm.ci_sa sa
left join cisadm.ci_ft ft on (sa.sa_id = ft.sa_id)
left join cisadm.ci_SA_Char sc on (sa.sa_id = sc.sa_id)
group by SA.ACCT_ID,SA.SA_ID,sc.char_type_cd,sc.char_val, sa.tot_to_bill_amt,sa.START_DT)
Where Deposit_Rnk=1


SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
9,826 questions
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,362 questions
SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,102 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Olaf Helper 29,041 Reputation points

    SELECT /+parallel(8)/

    I know this query hint "parallel" from Oracle
    And the screenshot is SqlPlus, also Oracle.
    Right? Because this a forum for Microsoft SQL Server

    Anyway, please post table design as DDL, some sample data as DML statement and the expected result.