Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Linq inside SQL server ?

Posted on 2012-04-11
1
Medium Priority
?
342 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 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

604 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