Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Strange SQL problem

  • 20-05-2009 10:19AM
    #1
    Registered Users, Registered Users 2 Posts: 528 ✭✭✭


    Hi guys,

    I have an SQL query I am running. The query looks as follows;

    SELECT TIME_STAMP, MSISDN, SUM(SUCCESS_2G), SUM(SUCCESS_3G)
    FROM
    (
    SELECT D.TIME_STAMP, I.MSISDN, A.SUCCESS SUCCESS_2G, 0 SUCCESS_3G
    FROM TABLE_1 A, DAY_TIME_DIMENSION D, IMSI_MAPPING I
    --WHERE D.TIME_STAMP = TRUNC((SYSDATE-75),'DD')
    WHERE D.DATE_ID BETWEEN 3348 AND 3354
    AND A.IMSI_ID=I.IMSI_ID
    AND A.DATE_ID=D.DATE_ID
    AND I.MSISDN=12345678
    UNION
    SELECT D.TIME_STAMP, I.MSISDN, 0 SUCCESS_2G, B.SUCCESS SUCCESS_3G
    FROM DAY_TIME_DIMENSION D, TABLE_2 B, IMSI_MAPPING I
    --WHERE D.TIME_STAMP = TRUNC((SYSDATE-75),'DD')
    WHERE D.DATE_ID BETWEEN 3348 AND 3354
    AND B.IMSI_ID=I.IMSI_ID
    AND B.DATE_ID=D.DATE_ID
    AND I.MSISDN=12345678
    )
    GROUP BY MSISDN

    When I run the query in DBvisualiser it works fine but when I try and run it on a linux system it just hangs. I have tried altering the query but nothing seems to work. Any suggestions. Thanks in advance.


Comments

  • Registered Users, Registered Users 2 Posts: 68,173 ✭✭✭✭seamus


    Looks like it might be a pretty hefty query. What DMBS are you using?


  • Registered Users, Registered Users 2 Posts: 528 ✭✭✭ridonkulous


    Figured it out. Thanks anyway. Mods close thread if you wish.


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    I'm unsure how the query is working anywhere.

    TIME_STAMP is neither a grouped expression nor a group-by expression in the outer query. This should be illegal....unless somehow TIME_STAMP is a system-level reserved word, in which case it would seem very strange that is it also defined as a column-name in TIME_DIMENSION.

    Assuming I'm missing something there, I'd delete the commented out lines, just in case there's a problem with the interpreter somehow handling them strangely.


Advertisement