Solved

Linq inside SQL server ?

Posted on 2012-04-11
1
327 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
[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
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

730 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