dotjoon — 2011-01-05T18:07:27-05:00 — #1
[b]data in myTable[/b]
<font color='"Blue"'>id name country city sex</font>
1 john <font color='"Red"'>America</font> Denver <font color='"Green"'>male</font>
[B]2[/B] Mary England London female
[B]3[/B] Judy France Chicago female
4 Tom German Berlin <font color='"green"'>male</font>
5 Carol <font color='"red"'>America</font> <font color='"Blue"'>Paris</font> female
6 Jane <font color='"red"'>America</font> Tokyo female
I have data in myTable like the above.
when I have America(weight 80%), Paris(weight(50%), and male(weight 20%) as 3 keywords,
I like to output like the below.
(1) Carol // 80%+50%=150%(total weight)
(2) John // 80%+20%=120%
(3) Jane // 80%
(4) Tom // 20%
(5) Mary // 0%
(6) Judy // 0% Judy comes later than Mary because of "ORDER BY [B]ID[/B]"
The following code doesn't work correctly, but I hope it shows what I want.
select name from myTable
order by ID
r937 — 2011-01-05T22:31:04-05:00 — #2
not even close
is that really your best attempt, after all the hundreds of times i have helped you with SQL???
well, sort of
i don't understand why you have a WHERE clause, because it looks like you want all rows returned
furthermore, you neglected to mention where the percentages are stored
dotjoon — 2011-01-05T23:11:00-05:00 — #3
Not really, Soorry, I might focus on the showing my target instead of making the real code.
I forgot, I am afraid, many parts of your point.
I work in another field for money although my dream is in this field.
Neither do I.
As I found that I should put the weight phrase in ORDER clause, I can't modify the OP because of sitePoint's preventing "EDIT" by time-passing.
percentages could be Dynamic.
Server language Page can give the percentages Dynamically. or DataBase can give it.
Let's suppose that Database has the percentTable like the below.
[b]data in percentTable[/b]
dotjoon — 2011-01-06T15:58:54-05:00 — #4
I have to add one more thing,
I've never asked about weight before.
This question is the first time relating weight.
Come on, Rudy, please...