[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Create a Array start # to end # In Crystal

Posted on 2014-04-02
4
Medium Priority
?
350 Views
Last Modified: 2014-04-02
I have yet another crazy Crystal approach where a SQL table {dbo.sales} timestamps a batch of created ticket numbers for example a sale where a client purchased qty 50 tickets on datetime and the starting number is 12340 and ending number 12389.

I have another table {dbo.transactions} when these actual tickets are being used for example on {dbo.datetime} ticket number 12341 was used.

I want to create a Crystal formula (@TicketSold) where the ticket number used checks the {dbo.Sales} table or however and shows the date when this 'used ticket' was created.

I'm guessing that each time tickets are sold (qty) I want to create an array reference with that date for the start to end numbers.
0
Comment
Question by:John-S Pretorius
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 39972827
Is there a single record in the dbo.sales table for the entire transaction or does each ticket have its own record.

If each ticket sold has a record then simply add the sales table and link on the ticket number to the transaction table.
There will be no lookup as you see just use the date sold field in the report.

 If there is a range you have other options
1.  Use a SQL Expression
2.  Use a subreport linked on the ticket number
3.  Use a Crystal Command

What database do you have?
If it is Oracle the first option is probably not available.

The third will be something like

SELECT dbo.transactions.ticketNumber, dbo.transactions.transactiondate, dbo.sales.salesdate, other fields you need
FROM dbotransactions INNER JOIN dbo.sales ON dbo.transactions.ticketnumber >= dbo.sales.ticketnumberfirst AND dbo.transactions.ticketnumber <= dbo.sales.ticketnumberlast

You may have to do the join  filter in the where clause
SELECT dbo.transactions.ticketNumber, dbo.transactions.transactiondate, dbo.sales.salesdate, other fields you need
FROM dbotransactions, dbo.sales
WHERE
dbo.transactions.ticketnumber >= dbo.sales.ticketnumberfirst AND dbo.transactions.ticketnumber <= dbo.sales.ticketnumberlast

mlmcc
0
 

Author Comment

by:John-S Pretorius
ID: 39972851
It is a SQL Database and each sale is typically part of a range, so if just ticket is being sold it's ok since the {dbo.FromNumber} and the {dbo.ToNumber} will be the same but if the quantity is more than 1 I just have a datetime stamp with a quantity.

Would another approach be possible to have a looped Array "FromNumber' to 'ToNumber as a global variable which runs against all sales in a subreport.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 39973238
Crystal works on 1 record at a time so looping really doesn't exist.

You can try a SQL expression

(
   SELECT   dbo.sales.CustomerID FROM dbo.sales WHERE dbo.sales.FromNumber <= {dbo.transaction.TicketNumber} AND dbo.sales.ToNumber >= {dbo.transaction.TicketNumber}
)

You can also use a subreport.
Link it on the ticket number
selecting on FromNumber

You can then edit the selection formula in the subreport to be

dbo.sales.FromNumber <= {?pm_TickectNumber} AND dbo.sales.ToNumber >= {?pm_TickectNumber}


mlmcc
0
 

Author Closing Comment

by:John-S Pretorius
ID: 39973259
Thank you
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question