?
Solved

Create a Array start # to end # In Crystal

Posted on 2014-04-02
4
Medium Priority
?
349 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month10 days, 4 hours left to enroll

762 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