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.
| Author |
Topic |
|
geossl
Yak Posting Veteran
85 Posts |
Posted - 2007-09-06 : 23:56:08
|
| Dear All, I would like to make a report which contains: <Product> <hasSupport> <hasWarranty> aaaa Yes Yes BBB Yes Nofrom three tables:Product:IDNameSupportLog: (one to many)SLogIDProductID:SupportDate:WarrantyLog: (one to many)WLogIDProductID:WarrantDate:Can I make this report using one SQL?Thanks. |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-07 : 02:37:06
|
| [code]SELECT [Product] = P.ID, [hasSupport] = CASE WHEN EXISTS (SELECT * FROM SupportLog AS SL WHERE SL.ProductID = P.ID) THEN 'Yes' ELSE 'No' END, [hasWarranty] = CASE WHEN EXISTS (SELECT * FROM WarrantyLog AS WL WHERE WL.ProductID = P.ID) THEN 'Yes' ELSE 'No' ENDFROM Product[/code]Kristen |
 |
|
|
|
|
|