Home » SQL & PL/SQL » SQL & PL/SQL » exception with select query (oracle 10g)
exception with select query [message #418655] Tue, 18 August 2009 00:34 Go to next message
rajasekhar857
Messages: 500
Registered: December 2008
Senior Member
SELECT *
FROM
  (SELECT MEDICATION_NAME,
    MEDICATION_REASON,
    DOSAGE_FORM,
    DOSAGE,
    START_DATE,
    END_DATE,
    MEDICATION_YEAR,
    MEDICATION_MONTH,
    END_YEAR,
    END_MONTH,
    MEDICATION_ID,
    MEDICATION_TYPE,
    ENCOUNTER_ID,
    GENERIC_NAME,
    PATIENT_ID,
    STATUS
  FROM EMRMedication
  WHERE MEDICATION_ID NOT IN
    (SELECT MEDICATION_ID
    FROM EMRMEDICATION EMD
    INNER JOIN EMRPRESCRIPTIONS EPR
    ON EMD.START_DATE      = EPR.PRESCRIPTION_CREATED_DATE
    AND EMD.MEDICATIONS_ID = EPR.MEDICATIONS_ID
    WHERE EMD.PATIENT_ID   = '72'
    )
  AND PATIENT_ID = '72'
  AND STATUS     = 1
  AND PATIENT_ID = '72'
  AND STATUS     = 1
  ) AS E --exception coming here
WHERE (MEDICATION_ID IN
  (SELECT MAX(MEDICATION_ID)
  FROM
    (SELECT MEDICATION_NAME,
      MEDICATION_REASON,
      DOSAGE_FORM,
      DOSAGE,
      START_DATE,
      END_DATE,
      MEDICATION_YEAR,
      MEDICATION_MONTH,
      END_YEAR,
      END_MONTH,
      MEDICATION_ID,
      MEDICATION_TYPE,
      ENCOUNTER_ID,
      GENERIC_NAME,
      PATIENT_ID,
      STATUS
    FROM EMRMedication
    WHERE MEDICATION_ID NOT IN
      (SELECT MEDICATION_ID
      FROM EMRMEDICATION EMD
      INNER JOIN EMRPRESCRIPTIONS EPR
      ON EMD.START_DATE      = EPR.PRESCRIPTION_CREATED_DATE
      AND EMD.MEDICATIONS_ID = EPR.MEDICATIONS_ID
      WHERE EMD.PATIENT_ID   = '72'
      )
    AND PATIENT_ID = '72'
    AND STATUS     = 1
    AND PATIENT_ID = '72'
    AND STATUS     = 1
    ) AS E1
  WHERE E1.ENCOUNTER_ID IS NOT NULL
  AND E1.PATIENT_ID      = E.PATIENT_ID
  AND STATUS             = 1
  GROUP BY PATIENT_ID,
    MEDICATION_NAME,
    DOSAGE_FORM
  )
AND E.PATIENT_ID  = '72')
OR (ENCOUNTER_ID IS NULL
AND E.PATIENT_ID  = '72')
ORDER BY MEDICATION_NAME




getting exeption marked as --

facing problem with this select query
Re: exception with select query [message #418657 is a reply to message #418655] Tue, 18 August 2009 00:39 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
>getting exeption marked as --
I do not have DDL
I do not have data.
I do not have exception.
I do not have solution & why should I?
Re: exception with select query [message #418658 is a reply to message #418655] Tue, 18 August 2009 00:51 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Use SQL*Plus and copy and paste your session.
Also always post your Oracle version with 4 decimals.

Regards
Michel
Re: exception with select query [message #418659 is a reply to message #418657] Tue, 18 August 2009 00:52 Go to previous messageGo to next message
rajasekhar857
Messages: 500
Registered: December 2008
Senior Member
my exception is
Error at Command Line:32 Column:4
Error report:
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
Re: exception with select query [message #418667 is a reply to message #418659] Tue, 18 August 2009 01:11 Go to previous message
rajasekhar857
Messages: 500
Registered: December 2008
Senior Member
I got my problem solved by removing AS keywords.Anyway thanks for
looking into my problem
Previous Topic: Problem with SQL (oracle)
Next Topic: All the Oracle Scripts in Single XML File
Goto Forum:
  


Current Time: Thu Dec 08 10:39:16 CST 2016

Total time taken to generate the page: 0.09929 seconds