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

Thread: SQL Query to Retrieve single row.

  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

  3. #3
    Join Date
    Nov 2021
    Posts
    4
    u can try it as below sql.

    select distinct * from tableName where 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