February 24, 2009 at 7:25 am
I have table
Material_Name Material_Type Consumer Day Night
IC 2 Idiv Day
Diode 4 Ediv Day
Capacitor 10 Udiv Night
Capacitor 10 Udiv Day
Another Table
Date Consumer Store Qty.
01/20/2008 Idiv New 120
02/12/2009 Ediv East 140
12/21/2008 Udiv Easr 1000
I want ouput like
Date Material_Name\Material_Type Consumer Day Night Store
01/20/2008 IC\2 Idiv Day N\A New
02/12/2009 Diode\4 Ediv Day N\A East
12/21/2008 Capacitor\10 Udiv Day Night East
can somebody help me for select statement?
February 24, 2009 at 7:37 am
Be happy to help, but we don't like to do homework or answer interview questions for you. We want to see you make an attempt at this.
You want to join the tables on some common field. You'd use a SELECT to get your columns, a FROM with the table names separated by INNER JOIN and then use an ON clause to show which columns need to match.
Look at some examples and make an attempt;
February 24, 2009 at 7:41 am
Without having the actual table names, this is about the closest I can get on this:
select
Date,
Material_Name + '\' + Material_Type as [Material_Name\Material_Type],
Table1.Consumer,
case [Day]
when 'Day' then 'Day'
else 'N/A'
end as [Day],
case [Day]
when 'Night' then 'Night'
else 'N/A'
end as Night,
Store
from dbo.Table1
inner join dbo.Table2
on Table1.Consumer = Table2.Consumer;
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply