Solved

SQL View

Posted on 2009-04-08
6
223 Views
Last Modified: 2012-05-06
Hello:

This is my query;
SELECT     TOP 100 PERCENT dbo.vw_empresa_info.Cliente, dbo.vw_empresa_info.Comercial, ISNULL(dbo.vw_info_citas4wk.ONDATEA, '01/01/01')
                      AS Citas4wkChk
FROM         dbo.vw_info_citas4wk RIGHT OUTER JOIN
                      dbo.vw_empresa_info ON dbo.vw_info_citas4wk.Cliente = dbo.vw_empresa_info.Cliente AND
                      dbo.vw_info_citas4wk.Comercial = dbo.vw_empresa_info.Comercial

The problem is that I would like "Citas4wkChk" to be N, and if not, Y. How can I do this?

thanks,
Joseph
0
Comment
Question by:CEGE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 24097647
Im not sure I follow...is this a varchar field?  What values are you checking against?
0
 
LVL 1

Author Comment

by:CEGE
ID: 24097766
sorry.
Cliente      Comercial      Citas4wkChk
1+1 STUDIO      NATALIA      01/01/2001
25RANAS      VALONSO      01/01/2001
2ÈME      NATALIA      01/01/2001
3DDB      TELEMKT      01/01/2001


The Last column is a datetieme field, and the others are varchar. and I would like perhaps another field that is "Yes" or "No", if the value in the last column is = 01/01/2001.
0
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
ID: 24097786
I gotcha...and if there is no value, you want it to be Y?  This will say "yes" if the value is 1/1/1, no if it is not.  If you need it swapped, just switch them around.

SELECT     TOP 100 PERCENT dbo.vw_empresa_info.Cliente, dbo.vw_empresa_info.Comercial,
case when ISNULL(dbo.vw_info_citas4wk.ONDATEA, '01/01/01')  = '01/01/01' THEN 'Yes' Else 'no' end
                      AS Citas4wkChk
FROM         dbo.vw_info_citas4wk RIGHT OUTER JOIN
                      dbo.vw_empresa_info ON dbo.vw_info_citas4wk.Cliente = dbo.vw_empresa_info.Cliente AND
                      dbo.vw_info_citas4wk.Comercial = dbo.vw_empresa_info.Comercial
0
Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 24097948
FYI:

Your top 100 percent won't actually serve a purpose.  If you are planning on doing a top 100 PERCENT so that you can order, it won't actually order.

Here's an article I wrote on the topic that explains why:
http://sqlservernation.com/blogs/brandongalderisi/archive/2009/03/15/when-ordering-in-a-view-doesn-t-work.aspx
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 24098160
that looks like a neat site Brandon...I'll check it out.
0
 
LVL 1

Author Closing Comment

by:CEGE
ID: 31568054
Fantastic!!! That was it....very cool. thank you.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question