Created
June 10, 2010 20:10
-
-
Save rflynn/433562 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 15:47 <@comcor> I want to pull all records in english where there isn't a value available in ru | |
-- 15:47 <@comcor> but when there is a value in ru, I only want the ru | |
create table foo(id int, lang text); | |
insert into foo values(1,'en'); | |
insert into foo values(2,'ru'); | |
insert into foo values(3,'en'); | |
insert into foo values(3,'ru'); | |
select id,lang from foo; | |
select "desc",x.id,x.lang from (select id,lang from foo order by id,lang desc)as x group by id; | |
select "asc",x.id,x.lang from (select id,lang from foo order by id,lang asc)as x group by id; | |
-- $ sqlite3 :memory: < en-ru-comcor.sql | |
-- 1|en | |
-- 2|ru | |
-- 3|en | |
-- 3|ru | |
-- desc|1|en | |
-- desc|2|ru | |
-- desc|3|en | |
-- asc|1|en | |
-- asc|2|ru | |
-- asc|3|ru |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment