Skip to content
New issue

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

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

Already on GitHub? # 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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant