Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

query help

$
0
0

Hi All,

I need a qry to return the customer information and details of the recent order placed by the customer. sud also include the customers who hasnt placed any order
as well. Also, what indexes would be best suited for this query?

create table cust_master
(customerid int,
name varchar(100),
Address varchar(100),
telephone varchar(10),
email varchar(20)
)
go
insert into cust_master
select 101,'Frank','Boston','999999','frank@gmail.com'
union all
select 102,'Baron','UK','88888','baron@gmail.com'
union all
select 103,'Dezry','sdfdsf','111111','ddezz@gmail.com'
union all
select 104,'Ele','aaaaa','22222','ele@gmail.com'


create table sales_master
(SalesORderid int,
SalesOrderdate datetime,
Customerid int,
Productid varchar(10),
quantity int)
go

insert into sales_master
select 1,'20130101',101,'P1',3
union all
select 2,'20130201',101,'P2',1
union all
select 3,'20130301',101,'P3',2
union all
select 4,'20130301',102','P1',1
union all
select 5,'20130422',102,'P2',3
go

Thanks in Advance


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>