Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

U-SQL subquery question #121

Open
ivpadim opened this issue Feb 20, 2018 · 0 comments
Open

U-SQL subquery question #121

ivpadim opened this issue Feb 20, 2018 · 0 comments

Comments

@ivpadim
Copy link

ivpadim commented Feb 20, 2018

Guys I'm having a hard time trying to figure out how to do the next subquery

declare @ventas as table(
	semana		int,
	existencia	int
);

declare @semanas as table(
	semana		int
);


insert into @ventas
values (1, 10),(3, 9),(5, 8);

insert into @semanas
values (1), (2), (3), (4), (5);

select s.semana,
	  isnull(v.existencia, 
-- **** this part
(select top 1 existencia from @ventas where semana < s.semana order by semana desc) ) as existencia
from @semanas s
	left outer join @ventas v on v.semana = s.semana
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant