Solved

Linq inside SQL server ?

Posted on 2012-04-11
1
319 Views
Last Modified: 2012-04-17
Hello EE,

Lets say I have a query like this:

SELECT a.ID, a.Description,
[answer] = CASE WHEN a.ID=1 THEN 'Something'
    ELSE ( SELECT sum(x.Amount) END

FROM Table1 a
LEFT JOIN Table2 x on x.ID = a.ID
WHERE x.currentYear = 2011


ok my question is...
lets I would like to include a WHERE clause saying  where x.period = 10

is it possible to write that clause inside the Case when on the select? do to it like this:

ELSE ( SELECT sum(x.Amount) where x.Period = 10 )... ?

I  know i could write the clause after my left join but i need to know if there is a way to do like in vb.net some LINQ?

i hope my question is clear...
thanks
0
Comment
Question by:PhilippeRenaud
1 Comment
 
LVL 9

Accepted Solution

by:
keyu earned 500 total points
ID: 37836976
Hi,

Have a look with this article might helps you.

http://geekswithblogs.net/CodePersona/archive/2008/01/03/118232.aspx

http://www.linqpad.net/

Thanks,
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now