Friday, April 26, 2013

Sample Sql Queries


 Simple select command:

SELECT SUBPRODUCT_UID
  ,SUBPRODUCT_PROVIDER_UID
  ,SUBPRODUCT_TYPE_UID
  ,DESCRIPTION
  ,EXTERNAL_ID
  ,OPTION_ID
  ,NEGOTIABLE_OFFER_IND
  ,UPDATED_BY
  ,UPDATED_ON
  ,CREATED_ON
  ,CREATED_BY FROM schemaname.SUBPRODUCT

With Inner Join:

SELECT eft.AMOUNT AS AMOUNT,
  ceft.MERCHANT_ID AS MERCHANT_ID,
  ca.ACCOUNT_NUMBER AS ACCOUNT_NUMBER,
  bf.MBNA_CREDIT_CARD_NUMBER AS MBNA_CREDIT_CARD_NUMBER,
  ceft.CUSTOMER_FIRST_NAME AS CUSTOMER_FIRST_NAME,
  ceft.CUSTOMER_LAST_NAME AS CUSTOMER_LAST_NAME,
  btr.TRACE_ID AS TRACE_ID,
  ROWNUM
FROM schemaname.bt_fulfillment bf

INNER JOIN schemaname.balance_transfer_request btr
ON btr.bt_fulfillment_uid = bf.bt_fulfillment_uid

INNER JOIN schemaname.electronic_funds_transfer eft
ON eft.bt_fulfillment_uid = bf.bt_fulfillment_uid

INNER JOIN schemaname.creditor_eft ceft
ON ceft.ELECTRONIC_FUNDS_TRANSFER_UID = eft.ELECTRONIC_FUNDS_TRANSFER_UID

INNER JOIN schemaname.credit_account ca
ON ca.ELECTRONIC_FUNDS_TRANSFER_UID = ceft.ELECTRONIC_FUNDS_TRANSFER_UID

WHERE ((btr.TYPE ='CREATE_CREDIT' AND btr.STATUS ='PENDING')
OR (btr.TYPE ='RETRY_CREDIT' AND btr.STATUS ='PENDING'))
AND btr.RELEASE_DATE < CURRENT_TIMESTAMP

2 comments:

Unknown said...


I have found your blogs to be friendly and welcoming. Thanks for making this one. I really enjoy reading and surfing it. Try to visit my site @ www.imarksweb.org

Zea

Unknown said...

Awesome work done... thank you for the help