Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7582993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:34:25+00:00 2026-05-30T18:34:25+00:00

I’m running into some problems trying to understand how I can do this. Let’s

  • 0

I’m running into some problems trying to understand how I can do this. Let’s say I’m running a lottery. Some tickets, or bunches of tickets will sometimes turn out void, which will be marked by a void flag in my database. Each ticket also has an individual number, along with a transaction id.

For a report I would like to have these voided tickets split up into groups. These groups can be any size, be it numbers 1-2, or 100-560. Having these groups makes discarding these tickets much easier, rather than sifting through for individual numbers. For example, lets say I sell 1000 tickets, from 1-1000. Bunches 10-36, 100-164, and 276-340 are all void.

How can I get my report to display that as follows:

Lottery Name| Voided Ticket Series
Lucky 7     | 10-36
Lucky 7     | 100-164
Lucky 7     | 276-340

I have some tables in place, they have the following data structures. The void tickets table is as follows:

Ticket # | Transaction_ID | Seller_ID | 

and the transaction table:

Transaction_ID | Seller_ID | Asset_ID | Lottery_name
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:34:26+00:00Added an answer on May 30, 2026 at 6:34 pm

    One way to do it in Oracle, cribbed from here:

    SQL> CREATE TABLE voided_tix (
      2      ticket_#        NUMBER
      3  ,   transaction_id  NUMBER
      4  ,   seller_id       NUMBER
      5  );
    
    Table created.
    
    SQL> CREATE TABLE transactions (
      2      transaction_id  NUMBER
      3  ,   seller_id       NUMBER
      4  ,   lottery_name    VARCHAR2(20)
      5  );
    
    Table created.
    
    SQL> INSERT INTO voided_tix
      2  SELECT CASE
      3         WHEN ROWNUM BETWEEN  1 AND  27 THEN ROWNUM + 9
      4         WHEN ROWNUM BETWEEN 28 AND  92 THEN ROWNUM + 72
      5         WHEN ROWNUM BETWEEN 93 AND 157 THEN ROWNUM + 183
      6         END
      7  ,      1000 + ROWNUM
      8  ,      12345678
      9  FROM   DUAL
     10  CONNECT BY LEVEL <= 157
     11  ;
    
    157 rows created.
    
    SQL> INSERT INTO transactions
      2  SELECT
      3      1000 + ROWNUM
      4  ,   12345678
      5  ,   'Lucky 7'
      6  FROM DUAL
      7  CONNECT BY LEVEL <= 200;
    
    200 rows created.
    
    SQL> COL n            FOR 99
    SQL> COL lottery_name FOR A12
    SQL> COL range        FOR A20
    SQL> SELECT   ROW_NUMBER() OVER (ORDER BY b.grping) n
      2  ,        b.lottery_name
      3  ,        TO_CHAR(MIN(b.ticket_#))
      4           || DECODE(MIN(b.ticket_#)
      5              ,      MAX(b.ticket_#), NULL
      6              ,      '-' || MAX(b.ticket_#)) range
      7  FROM    (SELECT  a.ticket_#
      8           ,       MAX(a.grp)
      9                   OVER (PARTITION BY a.lottery_name
     10                         ,            a.seller_id
     11                         ORDER BY     a.ticket_#) grping
     12           ,       a.lottery_name
     13           FROM   (SELECT  vt.ticket_#
     14                   ,       CASE
     15                           WHEN vt.ticket_# - 1 <> NVL(LAG(vt.ticket_#)
     16                                                       OVER (PARTITION BY t.lottery_name
     17                                                             ,            vt.seller_id
     18                                                             ORDER BY     vt.ticket_#)
     19                                                   ,   vt.ticket_#)
     20                           THEN vt.ticket_#
     21                           END             grp
     22           ,       vt.seller_id
     23           ,       t.lottery_name
     24           FROM    voided_tix      vt
     25           ,       transactions    t
     26           WHERE   vt.seller_id      = t.seller_id
     27           AND     vt.transaction_id = t.transaction_id) a ) b
     28  GROUP BY b.grping
     29  ,        b.lottery_name
     30  ORDER BY b.grping
     31  ;
    
      N LOTTERY_NAME RANGE
    --- ------------ --------------------
      1 Lucky 7      10-36
      2 Lucky 7      100-164
      3 Lucky 7      276-340
    
    SQL>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.