Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports 8.5 Stored Procedures

Status
Not open for further replies.

cmetz

Technical User
Apr 9, 2002
21
US
I have written a procedure and I need some help.
I want to list a bunch of routes but also
have two different destination locations.
Here is part of the procedure:

routestops.routecode = 'NEC5-1'or routestops.routecode = 'NEC2-1' or routestops.routecode = 'NEC3-1'
or routestops.routecode = 'NEC7-1')
and customernumber='2086' and sequence <> '1'

I want to add customernumber='BOA014' so I want it to look like this:

and customernumber='2086' and customernumber='BOA014' and sequence <>'1'

It is not working, do I need brackets or something?

Thanks
 
try:

routestops.routecode in ('NEC5-1','NEC2-1','NEC3-1','NEC7-1')
and customernumber in ('2086','BOA014')
and sequence <>'1'
 
Thanks so much, that worked perfectly.
 
What would I write in the procedure to then
group by the customer numbers?

Thanks
 
In your procedure, you will need to add a group by statement.

Group By customernumber

Keep in mind that the other fields in your proc's select statement will either need to be include in the group by or have some kind of compute (MAX, MIN, SUM, AVG) performed within your select statement.

For example:

Select
customernumber
,MAX(customername) customername
,SUM(miles) miles
,routecode
FROM table
WHERE
Group BY customernumber, routecode

This example will actually return a row for each customer number and routecode. I MAX on customername because that should not change from trip to trip.

Hope this helps.

KCM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top