Questions tagged [outer-apply]
65 questions
0
votes
0 answers
converting it to one simple query
I want to optimize the query to a simple one by having one select statement instead of these many sub queries and by converting the outer apply to left outer join. is it possible?
select (select LTRIM(pr.ProcRle)+',' as [text()]
from ( …

Shiva Kumar
- 33
- 1
- 7
0
votes
0 answers
Looping down a list of names and extracting data frame from a list of data frames
I have a list that stores 142 data frames
I have extracted the names of them into a vector
d.names[1]
[1] "ACQ_C.XPT"
I used a function to create a true/false vector which contains a list of variables in each data frame that I wish to either…

Abbas Ali
- 1
- 1
0
votes
1 answer
Violation of PRIMARY KEY constraint when using cross apply and outer apply together
I was using Microsoft SQL Server. I want to use both functions to parse data going into my table. So I use cross apply and outer apply together.
CROSS APPLY CA_Parse_CorpActnDtls_fn(MessageID) ent
outer apply…

Rachel
- 349
- 1
- 3
- 19
0
votes
1 answer
SQL Server 2012 Merge Records in OUTER APPLY related table
I have a Table "Customers" with customers details and Table "CALLS" where I store the result of each phonecall
When I need to get a list of the customers I have to call I use this query
SELECT *
FROM (
SELECT TOP (50)…

Joe
- 1,033
- 1
- 16
- 39
0
votes
2 answers
INSERT results into new table
Is it possible to INSERT the result of the following query into new table
SELECT
O.[full name],
O.[EID],
O.[Loc],
GL.*
FROM
[dbo].[team] O
OUTER APPLY
[dbo].[fngetlocdetail] (O.[eWorkCity]) GL
As standalone it works but…

ANASI-Newbie
- 111
- 8
0
votes
1 answer
Outer Column reference in an aggregate function of a cross apply
In my query, I am using OUTER APPLY to get employee count in different scenarios like
Number of Employees Joined in each day of a period
Number of Employees Resigned in each day of a period
Number of employees leave on each day of a period...…

Abdul Rasheed
- 6,486
- 4
- 32
- 48
0
votes
1 answer
OUTER APPLY in SQLAlchemy
I want to write a SQL Server's outer apply query like the one below using SQLAlchemy.
The FX table may not have the corresponding row on the date in the price table, so I need to use to OUTER APPLY to get the last row in the FX table for each date.…

Hei
- 70
- 6
0
votes
2 answers
Outer Apply combine 2 rows into 1 row and 2 columns
I am trying to write a query that combines multiple Outer Apply join results into single rows of data. I have played around with some CTEs but I just cant wrap my head around the solution.
I would like to have the multiple join results display as 1…

Orin Moyer
- 509
- 2
- 7
- 13
0
votes
1 answer
alternative for outer apply
This is my tables
create table #vehicles (vehicle_id int, sVehicleName varchar(50))
create table #location_history ( vehicle_id int, location varchar(50), date datetime)
insert into #vehicles values
(1, 'MH 14 aa 1111'),
(2,'MH 12 bb…

Swapnil
- 9
- 1
- 2
0
votes
2 answers
Alternate way for outer apply in SQL Server
I have a query in SQL server in which I have used outer apply. Now I want to convert it so that query can run on SQL server and MySQL also.
select top 5 v.sVehicleName as VehicleNo, ll.Location
from vehicles v
outer APPLY
(select top 1…

suraj
- 11
- 6
0
votes
2 answers
Join sub query table to table function with outer apply using Entity Framework
I created a SQL Server query that gets the correct results by getting a distinct list of case id's and joins them to the fnGetRelatedCases table function. However, I am unable to create an Entity Framework query that does the same.
SQL Server:
…
0
votes
2 answers
Indexing WHERE clause of OUTER/CROSS APPLY with INCLUDE
I have read that indexing columns should be used when using a WHERE clause to restrict returned records (i.e. SELECT * from Table1 WHERE Field1 = 'abc').
Does this rule apply when using APPLY, as in
SELECT t.Field1,x.Field2 from Table1 t
OUTER…

Sam Cohen-Devries
- 2,025
- 2
- 18
- 35
0
votes
1 answer
Case Statement as vals Outer Apply
I am trying to add a computed column to a table. Currently I have the following CASE statement building a calculated column in a SELECT statement,
--but I want to use this column to determine subsequent columns (sooo.. adding a computed column is…

Orin Moyer
- 509
- 2
- 7
- 13
0
votes
1 answer
SQL Server Error Handling within OUTER APPLY
I am no expert at T-SQL and I've got an issue (or rather, I don't have an issue but I really think I should) which I hope you can shed some light on as to why.
I have a stored procedure (SQL Server 2012) which I believe should give me an error - but…

DaveyWavey
- 3
- 1
-1
votes
1 answer
Rewriting Outer apply to join for performance
Since I am not that familiar with Outer Apply, I am a bit lost with rewriting the one from my previous question to join. It worked well but not for large chunks of data. Any help with this appreciated.
Previous question

NihilisticWonder
- 3
- 3