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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to turn this sql statement into a crystal report

Status
Not open for further replies.

gieg

Technical User
May 19, 2003
1
US
I'm trying to generate a crystal report based on this sql statement.

SELECT distinct a.vehicleno, a.type, a.division, a.assignment, a.divisiondirector, a.makemodel
FROM vehicllookup a
WHERE a.vehicleno <= 999 and a.makemodel not like '%trailer%'
and a.vehicleno NOT IN (SELECT vehicleno FROM summarymileage where logperiodconv = 'March 2003' )
and a.vehicleno NOT IN (SELECT vehicleno FROM errors_vehicletriplog_tmp where logperiodconv = 'March 2003' )
and a.vehicleno NOT IN (SELECT vehicleno FROM staffsummarymileage where logperiodconv = 'March 2003' )
and a.vehicleno NOT IN (SELECT vehicleno FROM errors_stafftriplog_tmp where logperiodconv = 'March 2003' )
and a.vehicleno NOT IN (SELECT vehicleno FROM CentralVehiclePool where logperiodconv = 'March 2003' )
and a.vehicleno NOT IN (SELECT vehicleno FROM CentralVehiclePool_MarchData where logperiodconv = 'March 2003' )
and a.vehicleno NOT IN (SELECT vehicleno FROM Errors_CentralVehiclePool_Tmp where logperiodconv = 'March 2003' )
and a.vehicleno NOT IN (SELECT vehicleno FROM PoliceSummaryMileage where logperiodconv = 'March 2003' )
and a.vehicleno NOT IN (SELECT vehicleno FROM Errors_PoliceTripLog_Tmp where logperiodconv = 'March 2003' )
 
I'm not sure I'd try..Unless your tables are very small and very carefully indexed, you need to look at that Sql and maybe find a way to eliminate all those NOT IN clauses and the LIKE with wild cards at start and end: They are perhaps the most inefficient Sql statements you can run..
Look at your indexes, try to pre-create staging tables or use Stored Procedures to return a ref cursor ( If in Oracle) with the data you need...

In general, refine the query first, then use Crystal to get the format you like..

Just a pointer, not a criticism...
[profile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top