Tuesday, May 22, 2018

SQL:

## Used for show table name whose column name is user input :

SELECT TABLE_NAME FROM USER_TAB_COLUMNS
WHERE UPPER(COLUMN_NAME)='COLUMN_NAME'

     Sub query :

select  appoint_date,doc_name,doctor_no,doc_chember, sum(tot_app) tot, sum(in_pat) in_pat,
(select room_name from hpms_room where room_no=a.doc_chember) room_no
from(
    select appoint_date,doctor_no,doc_chember, doc_name,tot_app,  in_pat
    from
         (select appoint_date,doctor_no,doc_chember,fnc_doctorname(doctor_no) doc_name,count(APPOINT_NO) tot_app,(select count(APPOINT_NO) from op_patientmovement
        where trunc(entry_timestamp) between  trunc(sysdate-120) and sysdate and consult_no = a.appoint_no and movement_type_no=6 ) in_pat
        from op_appointment a
        where trunc(appoint_date) between  trunc(sysdate-120) and sysdate
        and trunc(appoint_date) between nvl(to_date(:p_form_date,'dd/mm/rr'), appoint_date) and nvl(to_date(:p_to_date,'dd/mm/rr'),appoint_date)
        group by doctor_no,appoint_no,appoint_date,doc_chember)
    )    a
group by doc_name,appoint_date,doctor_no,doc_chember
order by appoint_date desc;

-----------------------------------------

Related Posts:

  • Function : A function has a return type in its specification and must return a value specified in that type. … Read More
  • Procedure : A procedure does not have a return type and should not return any value but it can have a return statement that simply stops its execution and returns to the caller. A procedure is used to return multiple values otherwise it… Read More
  • Regular expression example --remarks  :=== wU K‡i U¨ve‡jU  ‡L‡Z n‡e  (1 w`b)#1  Tab  by mouth  for 1 Days   select    regexp_substr(remarks,'[^#]+',1,2)     from pm_presmedicine    will … Read More
  • For Loop : Example : In this example used a pakage pkg_mm.prcinsitemstk <<Pakage>> <<Procedure>>  PROCEDURE prc_insitemstk (       p_column_name   IN   VARCHAR2, &n… Read More
  • Read More

0 comments:

Post a Comment