Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Nested Select queries i main select query LINQ

Nested Select queries i main select query LINQ

Scheduled Pinned Locked Moved C#
databasecsharpsql-serverlinqcom
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tridip Bhattacharjee
    wrote on last edited by
    #1

    apologized for asking a help for linq query. i hardly use LINQ rather i use MSDAAB as DAL which i use to execute my inline sql query or my db store procedure etc. now i am in situation where i need to use LINQ to extract data from datatable. here i am attaching one screenshot like how my data look like enter image description here http://i.stack.imgur.com/NMrvR.png[^] the is data is coming from sql server and for which i am using the below query for sql server. please see my query first. select (select count(*) as incoming from tridip_Interval where direction='I' and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and Is_Internal=0 and continuation=0 and RIGHT(convert(varchar,[call duration]),8)<> '00:00:00' and party1name='Train5') as incoming, (select count(*) as OutGoing from tridip_Interval where direction='O' and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and Is_Internal=0 and continuation=0 and party1name not in ('Voice Mail') and party1name='Train5') as OutGoing, (select count(*) as CallTransfer from tridip_Interval where continuation=1 and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and RIGHT(convert(varchar,[call duration]),8)<> '00:00:00' and party1name not in ('Voice Mail') and party1name='Train5') as CallTransfer, (SELECT count(*) as UnansweredCalls_DuringBusinessHours from tridip_Interval where direction='I' and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and RIGHT(convert(varchar,[call duration]),8)= '00:00:00' and [Ring duration]>0 and party1name='Train5') as misscall now i want to use LINQ to query data table but hence i am not good in linq so not being able to compose the above sql like query with linq. so just wonder if any guy help me to compose the above query with linq. apologized could not highlight my linq query because very honestly i know linq little and that is the reason things is not coming to my mind how to compose the same above sql query with LINQ. looking for hep and support.

    tbhattacharjee

    M 1 Reply Last reply
    0
    • T Tridip Bhattacharjee

      apologized for asking a help for linq query. i hardly use LINQ rather i use MSDAAB as DAL which i use to execute my inline sql query or my db store procedure etc. now i am in situation where i need to use LINQ to extract data from datatable. here i am attaching one screenshot like how my data look like enter image description here http://i.stack.imgur.com/NMrvR.png[^] the is data is coming from sql server and for which i am using the below query for sql server. please see my query first. select (select count(*) as incoming from tridip_Interval where direction='I' and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and Is_Internal=0 and continuation=0 and RIGHT(convert(varchar,[call duration]),8)<> '00:00:00' and party1name='Train5') as incoming, (select count(*) as OutGoing from tridip_Interval where direction='O' and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and Is_Internal=0 and continuation=0 and party1name not in ('Voice Mail') and party1name='Train5') as OutGoing, (select count(*) as CallTransfer from tridip_Interval where continuation=1 and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and RIGHT(convert(varchar,[call duration]),8)<> '00:00:00' and party1name not in ('Voice Mail') and party1name='Train5') as CallTransfer, (SELECT count(*) as UnansweredCalls_DuringBusinessHours from tridip_Interval where direction='I' and CONVERT(datetime,right([Call Start],8)) >='08:30:00' and CONVERT(datetime,right([Call Start],8)) <='09:00:00' and RIGHT(convert(varchar,[call duration]),8)= '00:00:00' and [Ring duration]>0 and party1name='Train5') as misscall now i want to use LINQ to query data table but hence i am not good in linq so not being able to compose the above sql like query with linq. so just wonder if any guy help me to compose the above query with linq. apologized could not highlight my linq query because very honestly i know linq little and that is the reason things is not coming to my mind how to compose the same above sql query with LINQ. looking for hep and support.

      tbhattacharjee

      M Offline
      M Offline
      Mathi Mani
      wrote on last edited by
      #2

      Hi, Here is the link which shows how to get count from LINQ query. http://stackoverflow.com/questions/3853010/get-item-count-of-a-list-using-linq[^] Here is link that shows how to query Datatable using LINQ: Working with LINQ to Entities & LINQ to DataTable[^]

      T 1 Reply Last reply
      0
      • M Mathi Mani

        Hi, Here is the link which shows how to get count from LINQ query. http://stackoverflow.com/questions/3853010/get-item-count-of-a-list-using-linq[^] Here is link that shows how to query Datatable using LINQ: Working with LINQ to Entities & LINQ to DataTable[^]

        T Offline
        T Offline
        Tridip Bhattacharjee
        wrote on last edited by
        #3

        basically i would have a main select and there will be some nested select like below

        SELECT EmployeeName,
        (Select count(*) from table1 where condition) as data1,
        (Select count(*) from table1 where condition) as data2,
        (Select count(*) from table1 where condition) as data3

        i like to know how to write nested select ? anyone can construct a sample one for me. thanks

        tbhattacharjee

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups