Solved

SQL View

Posted on 2009-04-08
6
211 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
  • 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Read about achieving the basic levels of HRIS security in the workplace.
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…

792 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