Commandolomo
Technical User
Hello All
Is it possible within an SQL statement to only bring back those records which have multiple instances of a value?
For example, the code below returns all orders as per the conditions :-
select (vc.Title + ' ' + vc.Fname + ' ' + vc.Sname) as clientname,
(vl.house + ' ' + vl.street + ' ' + vl.town + ' ' + vl.county + ' ' + vl.postcode) as client_address, (mo.status) as Service_Status, (vc.Sname + vc.Fname + mo.our_ref ) as sortkey, mo.report_to as DSO, mo.our_ref as Swift_ID, mo.order_id as Order_ID,
mo.client_id as MO_Client_ID, vc.client_id as VC_Client_ID
from vclient vc, vlocation vl, main_order mo, client_extra ce
where vc.location_id = vl.location_id
and
mo.client_id = vc.client_id
and
ce.client_id = vc.client_id
and
mo.status = '1'
- but I only want to bring back those records where there is multiple instances of the same Order ID - MO.Client_ID.
I have had to hit the ground running with regards to my SQL usage, so I apologise for my ignorance!!
If anyone has any pointers I would be most grateful.
Cheers
PJL
Is it possible within an SQL statement to only bring back those records which have multiple instances of a value?
For example, the code below returns all orders as per the conditions :-
select (vc.Title + ' ' + vc.Fname + ' ' + vc.Sname) as clientname,
(vl.house + ' ' + vl.street + ' ' + vl.town + ' ' + vl.county + ' ' + vl.postcode) as client_address, (mo.status) as Service_Status, (vc.Sname + vc.Fname + mo.our_ref ) as sortkey, mo.report_to as DSO, mo.our_ref as Swift_ID, mo.order_id as Order_ID,
mo.client_id as MO_Client_ID, vc.client_id as VC_Client_ID
from vclient vc, vlocation vl, main_order mo, client_extra ce
where vc.location_id = vl.location_id
and
mo.client_id = vc.client_id
and
ce.client_id = vc.client_id
and
mo.status = '1'
- but I only want to bring back those records where there is multiple instances of the same Order ID - MO.Client_ID.
I have had to hit the ground running with regards to my SQL usage, so I apologise for my ignorance!!
If anyone has any pointers I would be most grateful.
Cheers
PJL