Results 1 to 3 of 3

Thread: ASP, VBscript, SQL Union Select and Record sets [Resolved]

  1. #1

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774

    ASP, VBscript, SQL Union Select and Record sets [Resolved]

    I am devloping a new "function" for an ASP website. It is programmed purely in VBscript and uses a Micosoft Access Database.

    A loop is used to build an extensive union query. Each loop adds a line such as "...2 as Rel..." the number changes with each iteration dependant on a large array of different factors.

    Once we have this huge resord set from the database we will have a list where every entry appears up to Sixty times with only the Rel field being unique to any given line.

    What I now want to do is "Sum" on Rel and "Group by" on everything else. I hope there is a way to use SQL on my record set to pull a new record set from it.

    I am also hopeing that it does not mean writing a new table in the database each time to do it.

    What is the fastest way (In terms of server time) to get to the desired end result? (given that the database is huge and likely to grow endlessly untill we are forced to move to SQL server!)
    Last edited by Matt_T_hat; Apr 5th, 2004 at 04:58 AM.
    ?
    'What's this bit for anyway?
    For Jono

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    Well, assuming that your union (huge) query is inna string, you need to make it a subquery :

    Select field, field, (...etc) ,sum(rel) as sumofrel
    From
    (
    union query here
    )

    If your union query is run to put the data in a table, which I doubt as you wouldn't have posted up otherwise, then you can do the above but on that table.

    Why would you want to sum the `rels` anyway?


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    Originally posted by Ecniv
    Well, assuming that your union (huge) query is inna string, you need to make it a subquery :

    Select field, field, (...etc) ,sum(rel) as sumofrel
    From
    (
    union query here
    )

    You can do that!?! Fantastic! That's easy then. Thank you.

    Originally posted by Ecniv
    Why would you want to sum the `rels` anyway?
    The Sum of Rel should indicate the RELivence of a search term based on how many times it shows up and where.
    ?
    'What's this bit for anyway?
    For Jono

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width