Solved

Linq inside SQL server ?

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

785 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