Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 233147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:04:35+00:00 2026-05-11T20:04:35+00:00

I wonder if someone can help me. I want to replicate the following SQL

  • 0

I wonder if someone can help me. I want to replicate the following SQL query using LINQ in VB.Net.I’m a little unclear on how to do subqueries / aggregates.

Thanks

SELECT  *
FROM    Server S
    INNER JOIN ServerHDD H
            ON S.Server_ID = H.Server_ID
    INNER JOIN (SELECT      MAX(ServerHDD_ID) AS ServerHDD_ID
                            FROM    ServerHDD
                            GROUP BY Server_ID, Letter) Filter
            ON H.ServerHDD_ID = Filter.ServerHDD_ID
ORDER BY S.Hostname, H.Letter

Got this as below in C# => need VB.Net Conversion please.

from S in SERVER
join H in SERVERHDD on S.Server_ID equals H.Server_ID
join FILTER in 
    (from s in SERVERHDD group s 
            by new {s.Server_ID, s.Letter} 
            into groupedServerHDD select new 
                    {
                            SERVERHDD_ID = groupedServer.Sum(gS=>gS.ServerHDD_ID)
                    }
    )
     on H.ServerHDD_ID equals FILTER.SERVERHDD_ID 
     orderby S.Hostname, H.Letter
     select S
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:04:36+00:00Added an answer on May 11, 2026 at 8:04 pm

    This is my most favorite page regarding this topic. I love LINQ to SQL (and wish they intended to continue support for it over Entity Framework…) http://msdn.microsoft.com/en-us/vbasic/bb688085.aspx. On this page you will find all the answers to your querying needs. It is hard to format the query here without something to test it against!

    Your inner joins go away with the simple join syntax of LtS. You can either say .Max() on your inner select or Max(pseudo functoid here) like this:

    From p2 In g _
    Where p2.UnitPrice = g.Max(Function(p3) p3.UnitPrice) _
    Select p2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder whether someone can help me please. I'm using the following script to
I wonder if someone can help! I've been using following 'Get_Date' class with method
I wonder if someone can help me with this. I have a LINQ query
I wonder whether someone can help me please. I'm using the following script to
I wonder if someone can help me translate a MySQL query to a (Db)LINQ
wonder whether someone can help me with the following one... I have a struct
I wonder if someone can help: Long story short, I'm using MSSQL2005 to build
wonder if someone can help me i know what i want to achive but
I wonder whether someone can help me please. I have the following xml file
I wonder if someone can help me - I've been programming VB.Net for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.