Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 value mismatch using join

Author  Topic 

vidhya
Posting Yak Master

108 Posts

Posted - 2015-02-01 : 06:45:36
Furniture table
fid int(11)
furniturename varchar(50)
companyname varchar(30)
furnituredesign varchar(30)
quantity varchar(30)
color varchar(30)
Size varchar(30)
price varchar(30)
material varchar(30)
height varchar(30)
width varchar(30)


Sales table

Field
Type

salesid int(11)
fid int(11)
fsdate varchar(10)
quantity int(11)
eid int(100)

employee table
Field
Type

eid int(100)
fname char(100)
lname char(100)
dob varchar(100)
gender char(100)
address varchar(100)
status char(100)
contact int(100)
emailid varchar(100)
salary int(100)

select f.furniturename as furniturename,f.quantity as tquantity,s.quantity as squantity,e.fname as fname,e.lname as lname from furnitures f inner join sales s inner join employee e on s.fid=f.fid and e.eid=s.eid";

furniture Name Total Quantity Sales quantity Remaining Quantity person
book rack 40 2 roshan shri
book rack 40 3 roshan shri


It displays 2 records , but it should display in 1 record.output should be like this
bookrack 40 5 35 roshan shri

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-02-01 : 07:57:24
well you're not specifying any kind of sum in your query. So how would those two rows be added up to give you the 5 remaining?
Go to Top of Page
   

- Advertisement -