Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Help required with Joins

Help required with Joins

Scheduled Pinned Locked Moved Database
databasehelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rajiya
    wrote on last edited by
    #1

    Hi All, I am writing a query for a daily report generation. It involves data from 4 tables. Am so confused about which joins to use. It also makes use of GROUP BY CLAUSE on Cust_NBR and make use of agrregate function Count. I have written a query as follows but it's not working. Plz help me...as it is urgent. select SH.ARBL_NBR Airbill,S.cust_NBR Account_Number,S.Shpt_Id,S.City_Nam sender_City, S.St_Prvnc_Cd Sender_State,s.cntry_id Sender_Country,S.Postl_Cd sender_postal, S.Svc_Lvl_Cd Sender_Service_Area_Code, R.City_Nam Receiver_City,R.St_Prvnc_Cd Receiver_State,R.cntry_id Reciever_Country, R.Postl_Cd Receiver_Postal, R.Svc_Lvl_Cd Receiver_Service_Area_Code, U.Frst_Nam||' ' ||U.last_nam Name, S.STR_ADDR_1 Sender_Street_Address1, S.Str_Addr_2 Sender_Street_Address2 from shpt SH Right Outer Join shpt_addr S on sh.shpt_id = S.shpt_id Right Outer Join shpt_addr R ON S.shpt_id = R.shpt_id Right Outer Join Users U ON SH.User_Id = U.User_Id Right Outer Join Cust C On S.Cust_Nbr = C.Cust_Nbr where S.ADDR_TYP_CD = 1 and R.Addr_Typ_Cd = 2 and c.creat_dt between trunc(sysdate) and trunc(sysdate-90) group By S.Cust_Nbr Desc Having Count(sh.shpt_id >= 25)

    E 1 Reply Last reply
    0
    • R Rajiya

      Hi All, I am writing a query for a daily report generation. It involves data from 4 tables. Am so confused about which joins to use. It also makes use of GROUP BY CLAUSE on Cust_NBR and make use of agrregate function Count. I have written a query as follows but it's not working. Plz help me...as it is urgent. select SH.ARBL_NBR Airbill,S.cust_NBR Account_Number,S.Shpt_Id,S.City_Nam sender_City, S.St_Prvnc_Cd Sender_State,s.cntry_id Sender_Country,S.Postl_Cd sender_postal, S.Svc_Lvl_Cd Sender_Service_Area_Code, R.City_Nam Receiver_City,R.St_Prvnc_Cd Receiver_State,R.cntry_id Reciever_Country, R.Postl_Cd Receiver_Postal, R.Svc_Lvl_Cd Receiver_Service_Area_Code, U.Frst_Nam||' ' ||U.last_nam Name, S.STR_ADDR_1 Sender_Street_Address1, S.Str_Addr_2 Sender_Street_Address2 from shpt SH Right Outer Join shpt_addr S on sh.shpt_id = S.shpt_id Right Outer Join shpt_addr R ON S.shpt_id = R.shpt_id Right Outer Join Users U ON SH.User_Id = U.User_Id Right Outer Join Cust C On S.Cust_Nbr = C.Cust_Nbr where S.ADDR_TYP_CD = 1 and R.Addr_Typ_Cd = 2 and c.creat_dt between trunc(sysdate) and trunc(sysdate-90) group By S.Cust_Nbr Desc Having Count(sh.shpt_id >= 25)

      E Offline
      E Offline
      EBeylo
      wrote on last edited by
      #2

      Hi, what kind of Error do u get??

      R 1 Reply Last reply
      0
      • E EBeylo

        Hi, what kind of Error do u get??

        R Offline
        R Offline
        Rajiya
        wrote on last edited by
        #3

        Error i get is ORA-00933: SQL command not properly ended. There is some mistake in the query which i am not getting. Plz help me out.

        E 1 Reply Last reply
        0
        • R Rajiya

          Error i get is ORA-00933: SQL command not properly ended. There is some mistake in the query which i am not getting. Plz help me out.

          E Offline
          E Offline
          EBeylo
          wrote on last edited by
          #4

          Hi, try this please maybe the syntax problem is in the Having count-->

          select R.City_Nam Receiver_City,R.St_Prvnc_Cd Receiver_State,R.cntry_id Reciever_Country,
          R.Postl_Cd Receiver_Postal, R.Svc_Lvl_Cd Receiver_Service_Area_Code,
          U.Frst_Nam||' ' ||U.last_nam Name,
          S.STR_ADDR_1 Sender_Street_Address1, S.Str_Addr_2 Sender_Street_Address2
          from shpt SH
          Right Outer Join shpt_addr S
          on sh.shpt_id = S.shpt_id
          Right Outer Join shpt_addr R
          ON S.shpt_id = R.shpt_id
          Right Outer Join Users U
          ON SH.User_Id = U.User_Id
          Right Outer Join Cust C
          On S.Cust_Nbr = C.Cust_Nbr
          where S.ADDR_TYP_CD = 1 and R.Addr_Typ_Cd = 2
          and c.creat_dt between trunc(sysdate) and trunc(sysdate-90)
          group By S.Cust_Nbr Desc
          Having Count(sh.shpt_id) >= 25

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups