Home » SQL & PL/SQL » SQL & PL/SQL » unique rows
unique rows [message #203133] Tue, 14 November 2006 00:41 Go to next message
oracle_coorgi
Messages: 185
Registered: September 2006
Location: INDIA-karnataka
Senior Member
hi

SELECT DISTINCT L.LOC_ID,L.LOC_NM,L.LOC_CD,O.ORG_NM,CONCAT(A.LN1_TX, ' ' , A.LN2_TX) AS ADDRESS ,C.CNTRY_LONG_NM,A.CITY_NM,CASE L.ACTV_REC_IN WHEN 'Y' THEN 'Active' WHEN 'N' THEN 'InActive' ELSE NULL END AS STATUS FROM LOC AS L ,ORG_LOC AS OL ,ORG O,ADDR A,COUNTRY C WHERE L.LOC_ID=OL.LOC_ID AND O.ORG_ID=OL.ORG_ID AND A.RES_ID=L.LOC_ID AND C.CNTRY_ID=A.CNTRY_ID AND A.RES_TP_CD='LOC' ORDER BY L.LOC_NM

SELECT L.LOC_ID,L.LOC_NM,L.LOC_DESC,L.LOC_CD,O.ORG_NM,O.ORG_ID,AD.LN1_TX, AD.LN2_TX ,
AD.LN3_TX,AD.ZIP_CD,AD.PO_BOX_TX,AD.TIME_ZONE,ST.STATE_PRVNC_NM,C.CNTRY_ID,C.CNTRY_LONG_NM,AD.CITY_NM,CASE L.ACTV_REC_IN WHEN
'Y'
THEN 'Active' WHEN 'N' THEN 'InActive' ELSE NULL END AS STATUS
FROM ADDR AS AD,LOC AS L,ORG AS O left join ORG_LOC AS OL on
OL.ORG_ID=O.ORG_ID
LEFT JOIN
COUNTRY AS C ON
AD.CNTRY_ID=C.CNTRY_ID
LEFT JOIN
STATE_PRVNC AS ST ON
ST.STATE_PRVNC_ID = AD.STATE_PRVNC_ID
ORDER BY L.LOC_NM

i want only the loc_cd unique

thanxs
Re: unique rows [message #203141 is a reply to message #203133] Tue, 14 November 2006 01:18 Go to previous messageGo to next message
Littlefoot
Messages: 20891
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
SELECT DISTINCT loc_cd FROM loc;

Of course, I'm just kidding, but query you posted is unreadable. Format it a little bit and, possibly, explain what you are doing here.
Re: unique rows [message #203149 is a reply to message #203133] Tue, 14 November 2006 01:57 Go to previous message
pravin3032
Messages: 51
Registered: November 2006
Location: eARTH
Member
Hi !
i checked your first query,
you should check
1. join condition in the query is correct.
2. wether records are multiple for a loc_id in the related table.

good luck !
Previous Topic: Column Output in a Single Line with , seperated
Next Topic: select date
Goto Forum:
  


Current Time: Sun Dec 04 18:34:28 CST 2016

Total time taken to generate the page: 0.13923 seconds