Jump to content

sql babulu ravali


nenu_devudni

Recommended Posts

customer ki, telephone info ki 2 tables unay ... oka cust ki  multiple phone numb undochu .. so customer table lo oka row ki telephone table lo 2 rows undochu .. so ipudu nenu aa rendu tables ni join chesi telephone table meda outer join peta ..

select cust_name, etc, etc, phone_num, ext from customer, telephone_tab where customer.col1 = telephone.col1 (+)

ee info ni util dwara oka dat file loki extract chestuna ... prob endi ante .. outer join vala tele table lo una multiple vlaues kuda ostunay .. so edo oka value ee oche laga query rayali .. edi etla sadhyam .. kasta chepapdni .. podunundi kotuku chastuna  @~`

Link to comment
Share on other sites

Oracle / SQL Server aa man??..

edaina kuda you can use row_number() and get only one value... CTE use chesi, select from cte where rnum = 1 ani pettu only one record per customer vastundi... 

meanwhile you are not doing an outer join in this query only inner join... just fyi man...

Link to comment
Share on other sites

10 minutes ago, loveindia said:

Oracle / SQL Server aa man??..

edaina kuda you can use row_number() and get only one value... CTE use chesi, select from cte where rnum = 1 ani pettu only one record per customer vastundi... 

meanwhile you are not doing an outer join in this query only inner join... just fyi man...

venkatesh+comedy+GIF.gif

Link to comment
Share on other sites

16 minutes ago, loveindia said:

Oracle / SQL Server aa man??..

edaina kuda you can use row_number() and get only one value... CTE use chesi, select from cte where rnum = 1 ani pettu only one record per customer vastundi... 

meanwhile you are not doing an outer join in this query only inner join... just fyi man...

Oracle uncle $%^

Link to comment
Share on other sites

you can use rownumber or  select  select cust_name, etc, etc, phone_num, ext from customer Outer apply( select top 1 telephone from  telephone_tab where customer.col1 = telephone.col1   order by insertdate most recent kavali ante desc )

Link to comment
Share on other sites

edi query vuncle ..  telephone table lo multiple rows unte .. DECODE (ucrtele_tele_code, 'BU', 'AA', 'HM', 'AB', 'ZZ') based on this i have prioritize and select just one row ...@~`

 

 SELECT

result # 

cust_code lastname   area  number        ext        telecode 

1    CUST NAME1        901    3888515    NULL    BU    
1    CUST NAME1        901    4522682    NULL    BU
1    CUST NAME1        901    3215657    NULL   HM
1    CUST NAME1        901    3563942    NULL    CEL
1    CUST NAME1        901    3617623    NULL   CEL

 

Link to comment
Share on other sites

44 minutes ago, loveindia said:

Oracle / SQL Server aa man??..

edaina kuda you can use row_number() and get only one value... CTE use chesi, select from cte where rnum = 1 ani pettu only one record per customer vastundi... 

meanwhile you are not doing an outer join in this query only inner join... just fyi man...

venkatesh+comedy+GIF.gif

Link to comment
Share on other sites

aa select statement ki aa result ki relation ekkada undi man? Date field edanna undaa aa query lo... intaki aa 5 records which is the one you want to see man?

Link to comment
Share on other sites

;WITH CTE AS(
SELECT ucbcust_cust_code cust_code, 
           REPLACE(ucbcust_last_name,'|','') last_name,           
           upper(ucrtele_phone_area), 
           upper(ucrtele_phone_number),
           upper(ucrtele_phone_ext), 
           upper(ucrtele_tele_code),
           ROW_NUMBER() OVER(PARTITION BY ucbcust_cust_code ORDER BY ucrtele_tele_code) AS RNUM
      FROM ucbcust, ucrtele
      where ucbcust_cust_code = ucrtele_cust_code (+)
      and ucbcust_cust_code = 1
    ORDER BY DECODE (ucrtele_tele_code, 'BU', 'AA', 'HM', 'AB', 'ZZ')
)
SELECT *
FROM CTE 
WHER Rnum = 1

 

something like this will help you man...

Link to comment
Share on other sites

4 minutes ago, loveindia said:

ok my bad man... nuvvu (+) ani text editor anukunna... so its an actual left outer join...

  

MAAFF KARO vuncle .. ipudu dheko .. result 

cust_code lastname   area  number        ext        telecode 

1    CUST NAME1        901    3888515    NULL    BU    
1    CUST NAME1        901    4522682    NULL    BU
1    CUST NAME1        901    3215657    NULL   HM
1    CUST NAME1        901    3563942    NULL    CEL
1    CUST NAME1        901    3617623    NULL   CEL

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...