Hi I am using Crystal reports on SQL Server 2000
Any help would appreciated, still a newbie.
I wrote the following code to present data about laptops booked and in which rooms they are booked.
The error I am getting is
Failed to open a rowset
The column prefix ‘P2’ does not match with a table name or alias name used in the query.
Activity table holds information about events. Product table holds info about many things. One of these are laptops another thing is that it holds info about rooms as well.
There is no clear distinction between what is categorised as a laptop other than
Product.Prod_type = ‘IT Equipment’
And product.Prod_Name like ‘%laptop%’
As the latops would be named with no naming convention but would have the word laptop amongst the name.
The table are:
Product --- Activity_Xref --- Activity --- Activity_Xref2 --- Product2
Activity_Xref and Product table are joined twice in the query.
The reason for aliasing and joining the activity_Xref table and the Products table is because the report needs to identify which laptops are booked and in which rooms they will be used or if used externally then the room column will be null most likely.
The room column is Product.prod_name which would also be the field used for the laptop name.
Does this make sense so far.
The code is given below.
------------------------------------------------
Select P.prod_name
, P.Prod_type
, P2.Prod_name
, act.act_id
, act.act_id
, act.act_session_name
, act.act_action_date
, act.act_time
, act.act_end_date
, act.act_end_time
From (Activity as act inner join Activity_Xref
on act.act_Id = activity_Xref.ActXref_Act_ID)
Inner Join Product as p
on Activity_Xref.ActXref_Prod_Id = p.prod_id
Where P.prod_Type <> 'IT Equipment'
AND (P.PROD_NAME IS NULL OR (P.PROD_NAME='1 - Room A' OR P.PROD_NAME='2 - Room B' OR P.PROD_NAME='3 - Conference Room' OR P.PROD_NAME='4 - Training Room' OR P.PROD_NAME='5 - Lecture Theatre' OR P.PROD_NAME='6 - Library' OR P.PROD_NAME='7 - Commercial Affairs meeting room' OR P.PROD_NAME='8 - Training Room by Human Resources'))
and p2.prod_name in
(SELECT P2.Prod_Name From (Activity as activity2 Inner Join Activity_Xref as actX
on activity2.act_id = actX.ActXref_Act_Id)
Inner Join Product as P2 ON P2.Prod_Id = actX.ActXref_Prod_ID
Where P2.prod_Type = 'IT Equipment'
and p2.Prod_name like '%Laptop%')
ORDER BY act.act_id, act.act_action_date
------------------------------------------------
Thanks in advance
Idd
Any help would appreciated, still a newbie.
I wrote the following code to present data about laptops booked and in which rooms they are booked.
The error I am getting is
Failed to open a rowset
The column prefix ‘P2’ does not match with a table name or alias name used in the query.
Activity table holds information about events. Product table holds info about many things. One of these are laptops another thing is that it holds info about rooms as well.
There is no clear distinction between what is categorised as a laptop other than
Product.Prod_type = ‘IT Equipment’
And product.Prod_Name like ‘%laptop%’
As the latops would be named with no naming convention but would have the word laptop amongst the name.
The table are:
Product --- Activity_Xref --- Activity --- Activity_Xref2 --- Product2
Activity_Xref and Product table are joined twice in the query.
The reason for aliasing and joining the activity_Xref table and the Products table is because the report needs to identify which laptops are booked and in which rooms they will be used or if used externally then the room column will be null most likely.
The room column is Product.prod_name which would also be the field used for the laptop name.
Does this make sense so far.
The code is given below.
------------------------------------------------
Select P.prod_name
, P.Prod_type
, P2.Prod_name
, act.act_id
, act.act_id
, act.act_session_name
, act.act_action_date
, act.act_time
, act.act_end_date
, act.act_end_time
From (Activity as act inner join Activity_Xref
on act.act_Id = activity_Xref.ActXref_Act_ID)
Inner Join Product as p
on Activity_Xref.ActXref_Prod_Id = p.prod_id
Where P.prod_Type <> 'IT Equipment'
AND (P.PROD_NAME IS NULL OR (P.PROD_NAME='1 - Room A' OR P.PROD_NAME='2 - Room B' OR P.PROD_NAME='3 - Conference Room' OR P.PROD_NAME='4 - Training Room' OR P.PROD_NAME='5 - Lecture Theatre' OR P.PROD_NAME='6 - Library' OR P.PROD_NAME='7 - Commercial Affairs meeting room' OR P.PROD_NAME='8 - Training Room by Human Resources'))
and p2.prod_name in
(SELECT P2.Prod_Name From (Activity as activity2 Inner Join Activity_Xref as actX
on activity2.act_id = actX.ActXref_Act_Id)
Inner Join Product as P2 ON P2.Prod_Id = actX.ActXref_Prod_ID
Where P2.prod_Type = 'IT Equipment'
and p2.Prod_name like '%Laptop%')
ORDER BY act.act_id, act.act_action_date
------------------------------------------------
Thanks in advance
Idd