DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: SQL Query to Retrieve single row.

Hybrid View

  1. #1
    Join Date
    Aug 2021
    Posts
    1

    SQL Query to Retrieve single row.

    I have a table as below

    TX_ID Card No. Primary
    127 XXXX1234 0
    129 XXXX1234 0
    1245 XXXX1234 1
    1245 XXXX1234 0
    1245 XXXX1234 1

    Need to fetch the distinct of maximum of TX_ID value where the primary value is 1.
    The out put should be

    TX_ID Card No. Primary
    1245 XXXX1234 1

  2. #2
    Join Date
    Dec 2002
    Posts
    72
    You can use GROUP BY TX_ID, Card No. HAVING Primary=1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width