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

  • SEARCH
  • Home
  • 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 8184853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:38:59+00:00 2026-06-07T01:38:59+00:00

When I use this query, select receipt_num, trx_num, (case when receipt_amount > 5000 then

  • 0

When I use this query,

select 
   receipt_num, trx_num, 
   (case when receipt_amount > 5000 then '1' else 'null') as stamp_value,receipt_amount 
from ra_customer_all where receipt_amount > 5000;

It gives output lik this:

receipt_num             trx_num           stamp_value     receipt_amount
   23679                sf35fd                 1              5400
   23679                sdf2424                1              5400 
   23679                rer434                 1              5400
  987444                dgd343                 1              98432
    7610                sdf23                  1              6756
    7610                dfg242                 1              6756

But I want output to look like this:

receipt_num        trx_num        stamp_value      receipt_amount
  23679            sf35fd             1                 5400
  23679            sdf2424            null              5400
  23679            rer434             null              5400
 987444            dgd343             1                 98432
   7610            sdf23              1                 6756
   7610            dfg242             null              6756

Where the stamp value should print only one time for each receipt num > 5000.

(*A single receipt may contain one or more trx_num*)

Please help me with this.

select 
acra.attribute6 office_code,
acra.attribute5 collection_number,
acra.receipt_number instrument_number,
 acra.receipt_date collection_date,
 acra.amount collected_amount,
ac.customer_name,
rcta.trx_number ,
(case  row_number() over (partition by acra.receipt_number order by rcta.trx_number)  when acra.amount > 5000 then '1'  else 'NULL' end) stamp_value,
from
ar_cash_receipts_all acra,
ar_customers ac,
ra_customer_trx_all rcta,
ar_receivable_applications_all araa
where
acra.pay_from_customer=ac.customer_id and
acra.cash_receipt_id = araa.cash_receipt_id and
araa.applied_customer_trx_id=rcta.customer_trx_id
and acra.amount > 5000

okay,i update my join query in which i added partition by but gives error as missing keyword.Can someone edit this for desired output

  • 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-06-07T01:39:03+00:00Added an answer on June 7, 2026 at 1:39 am

    So you want stamp_value to be 1 for the first row in a group and NULL for all subsequent rows? Use PARTITION BY:

    select 
       receipt_num, trx_num, 
       (case row_number() over (partition by receipt_num order by trx_num) 
         when 1 then 1
         else NULL
         end) stamp_value,
       receipt_amount
    from ra_customer_all
    where receipt_amount > 5000
    

    This will set stamp_value to 1 for the first row (using trx_num for sorting) and NULL for all subsequent rows.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need report from multi table I use this query (SQL Server) Select CASE
well this is my problem i use 2 source first query (select * from
When I use this query: SELECT COUNT(*) FROM `my_table` WHERE DATEDIFF(NOW(), updated) > 2
In PhpMyAdmin I use this query: SELECT * FROM myrecords where TITLE LIKE %\\\%
User.id type INT Avatar.foreign_key type VARCHAR When I use this query: SELECT * FROM
I want to use this query: var queryData = from va in xdoc.Descendants(language) select
The answer to another SO question was to use this SQL query: SELECT o.Id,
now i use this code: $welcome_text = mysql_query(SELECT * FROM `text` WHERE `name` =
I'm currently trying to use this query SELECT a.id AS id, a.item AS item,
I have this query: SELECT DISTINCT phone, department FROM `users` WHERE ((SUBSTRING(phone,1,3) = '399')

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.