Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query Help Return only 1 line item per Cell

Status
Not open for further replies.

RHTexas

Technical User
Dec 5, 2011
7
US
Hi All,

I am new at SQL but I am doing my best to query two tables.

The below Query works but returns the same values 3 times for each.

Query:

SELECT
ERICSSON_UTRAN.RNC_UCELL_DY.DATETIME,
ERICSSON_UTRAN.RNC_UCELL_DY.RNC,
ERICSSON_UTRAN.RNC_UCELL_DY.UTRANCELL,

(PMTOTNORRCCONNECTREQCS) AS CS_RRC_ATTS,
(PMTOTNORRCCONNECTREQCSSUCC / (PMTOTNORRCCONNECTREQCS - PMNOLOADSHARINGRRCCONNCS)) * 100 AS CS_RRC_PERCENT,
(PMNORABESTABLISHATTEMPTSPEECH) AS CS_RAB_ATTS,
(PMNORABESTABLISHSUCCESSSPEECH / PMNORABESTABLISHATTEMPTSPEECH) * 100 AS CS_RAB_PERCENT,
(PMNOSYSTEMRABRELEASESPEECH) AS CS_DROPS,
(PMNOSYSTEMRABRELEASESPEECH / PMNORABESTABLISHSUCCESSSPEECH) * 100 AS CS_DROPS_RATE,
((PMNOSYSRELSPEECHSOHO - PMNOSYSRELSPEECHNEIGHBR) / PMNOSYSTEMRABRELEASESPEECH) * 100 AS SOHO_PERCENT,
(PMNOSYSRELSPEECHNEIGHBR / PMNOSYSTEMRABRELEASESPEECH) * 100 AS MISSING_NEIGH,
(PMNOSYSRELSPEECHULSYNCH / PMNOSYSTEMRABRELEASESPEECH) * 100 AS UL_SYNC,
(PMRLADDATTEMPTSBESTCELLSPEECH) AS CS_SHO_ATTS,
(PMRLADDSUCCESSBESTCELLSPEECH / PMRLADDATTEMPTSBESTCELLSPEECH) * 100 AS CS_SHO_SUCC_PERCENT,
((PMNOSUCCESSOUTIRATHOSPEECH + PMNOSUCCESSOUTIRATHOMULTI) / (PMNORABESTABLISHSUCCESSSPEECH)) * 100 AS IRAT_PERCENT,
((PMNOSYSTEMRABRELEASESPEECH - PMNOOFTERMSPEECHCONG - PMNOSYSRELSPEECHSOHO - PMNOSYSRELSPEECHULSYNCH - (PMNOATTOUTIRATHOSPEECH - PMNOFAILOUTIRATHOSPCHUEREJECT - PMNOSUCCESSOUTIRATHOSPEECH - PMNFOIRATHOSPCHCHNOTPHYCHFAIL - PMNFLOUTIRATHOSPCHCHPHYCHFAIL)) / PMNOSYSTEMRABRELEASESPEECH) * 100 AS OTHER_PERCENT,
((NVL(PMNOATTOUTIRATHOMULTI, 0) + NVL(PMNOATTOUTIRATHOSPEECH, 0) + NVL(PMNOATTOUTIRATHOSTANDALONE, 0) + NVL(PMNOATTOUTSBHOSPEECH, 0) + NVL(PMNOFAILOUTIRATHOMULTIGSMFAILR, 0) + NVL(PMNOSUCCESSOUTIRATHOSPEECH, 0) + NVL(PMNOFAILOUTIRATHOSPCHGSMFAIL, 0) + NVL(PMNOFAILOUTSBHOSPEECHGSMFAILRE, 0))) AS IRAT_HO_ATTS,
((PMNOSUCCESSOUTIRATHOSPEECH + PMNOSUCCESSOUTIRATHOMULTI) / PMNORABESTABLISHSUCCESSSPEECH) AS LOST_TO_GSM,
((PMSUMBESTCS12ESTABLISH / PMSAMPLEBSTCS12PSINTRABESTBLSH) + (PMSUMBESTAMR5900RABESTABLISH / PMSAMPLESAMR5900RABESTABLISH) + (PMSUMBESTAMR4750RABESTABLISH / PMSAMPLESAMR4750RABESTABLISH) + (PMSUMBESTAMR7950RABESTABLISH / PMSAMPLESAMR7950RABESTABLISH) + (PMSUMBESTAMR12200RABESTABLISH / PMSAMPLESAMR12200RABESTABLISH)) AS CS_ERLANGS

FROM
ERICSSON_UTRAN.RNC_UCELL_DY,
ERICSSON_UTRAN.RNC_GSMRELATION_DY

WHERE
substr(ERICSSON_UTRAN.RNC_UCELL_DY.UTRANCELL, 1, 7) IN ('TXU0001') AND
ERICSSON_UTRAN.RNC_UCELL_DY.DATETIME BETWEEN TO_DATE('27-DEC-2011 00:00:00', 'DD-MON-YYYY HH24:MI:SS') AND
TO_DATE('27-DEC-2011 23:59:59', 'DD-MON-YYYY HH24:MI:SS') and
ERICSSON_UTRAN.RNC_UCELL_DY.DATETIME= ERICSSON_UTRAN.RNC_GSMRELATION_DY.DATETIME and
ERICSSON_UTRAN.RNC_UCELL_DY.UTRANCELL=ERICSSON_UTRAN.RNC_GSMRELATION_DY.UTRANCELL

ORDER by
ERICSSON_UTRAN.RNC_UCELL_DY.DATETIME,
ERICSSON_UTRAN.RNC_UCELL_DY.UTRANCELL


The Query Returns this:
DATETIME RNC UTRANCELL CS_RRC_ATTS CS_RRC_PERCENT CS_RAB_ATTS CS_RAB_PERCENT CS_DROPS CS_DROPS_RATE
12/27/2011 AUSUTXNICRBR11 TXU00011 1052 99.42965779 1343 99.85107967 10 0.745712155
12/27/2011 AUSUTXNICRBR11 TXU00011 1052 99.42965779 1343 99.85107967 10 0.745712155
12/27/2011 AUSUTXNICRBR11 TXU00011 1052 99.42965779 1343 99.85107967 10 0.745712155

As you can see it repeats the TXU00011 3 times.

How do I get this query to return only one TXU00011.

Any helps is greatly appreciated...I went and bought two sql books but cant seem to get it figured out. :)

Also if there is a better way to code this I am al ears as well.

Cheers,

Ray
 
Have you checked the data in the database to make sure there isn't duplicate data?

If you know there is duplicate data, but you only want one row returned use DISTINCT

SELECT DISTINCT ......

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
Wait....I just noticed the 'TO_DATE' in your WHERE clause. Are you using Oracle? If so, this forum is for Microsoft SQL Server and you would be better off posting this in the appropriate forum.

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
Hi SQLBill,

Thank you very much for taking the time to help a stranger out.

The Distinct worked like a champ...Perfect! Thank you!

Also, I am using SQL...the database houses many days, hours, and minutes worth of data that I need to pull out for given times.

This is the only way I could figure out how to get the day and time I needed.

Is this the correct method in SQL?

Once again thank you very much!

Ray

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top