Re: [sqlite] SQL-Beginner question about filtering

2011-08-25 Thread Igor Tandetnik
Scholz Maik (CM-AI/PJ-CF42)  wrote:
> I am little bit confused about filtering SQL query's.
> 
> My table:
> ROWID   V   A   B
> ===
> 1   0   0   1
> 2   0   0   2
> 3   0   1   1
> 4   0   1   2
> 5   1   0   2
> 6   2   0   2
> 
> With my SQL knowledge I am able filter the result
> Like this:
> SELECT rowid,* from table WHERE V==0 | V==1;

I'm pretty sure you mean WHERE V=0 or V=1 . You can also write it as WHERE V in 
(0, 1) .  | is a bitwise-OR operator; it just happens to work in your case.

> But additionally, I need to eliminate duplicate (A+B)
> rows.
> My wanted result is:
> ROWID   V   A   B
> ===
> 1   0   0   1
> 3   0   1   1
> 4   0   1   2
> 5   1   0   2

Any particular reason you are choosing the row with ROWID of 5 and not 2? In 
other words, if you have duplicates, by what principle do you choose which row 
to keep?
-- 
Igor Tandetnik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] SQL-Beginner question about filtering

2011-08-25 Thread Scholz Maik (CM-AI/PJ-CF42)
Hi,
I am little bit confused about filtering SQL query's.

My table:
ROWID   V   A   B
===
1   0   0   1
2   0   0   2
3   0   1   1
4   0   1   2
5   1   0   2
6   2   0   2

With my SQL knowledge I am able filter the result
Like this:
SELECT rowid,* from table WHERE V==0 | V==1;
ROWID   V   A   B
===
1   0   0   1
2   0   0   2
3   0   1   1
4   0   1   2
5   1   0   2

But additionally, I need to eliminate duplicate (A+B)
rows.
My wanted result is:
ROWID   V   A   B
===
1   0   0   1
3   0   1   1
4   0   1   2
5   1   0   2

Anybody has a hint for a SQL beginner?

The operation shall be as compact as possible because
I have to run it on a embedded system with large tables.

Thanks in advance
Maik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users