|
|
|
Ну очень хитрый запрос.
|
|||
|---|---|---|---|
|
#18+
Ну очень хитрый запрос. Здравствуйте, знатоки. У меня есть к Вам вопрос. Вернее трудный "для меня" запрос. Есть 2 таблицы: table1 ------- id int ..... ------- table2 ------- id int number int ------- Мне нужно получить список всех id из table1 с указанием суммы всех number'ов для этого id, удовлетворяющих правилам rule 1 number like '8%' and not like '810%' rule 2 number like '810%' rule 3 number not like '8%' Вот нужные мне столбцы id, sum(number_rule1), sum(number_rule3), sum(number_rule3) вот такой ужасный запрос. Помогите кто может. Я исчерпал все свои знания. Заранее спасибо. Андрей. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.10.2002, 13:20:27 |
|
||
|
Ну очень хитрый запрос.
|
|||
|---|---|---|---|
|
#18+
rule 1 number like '8%' and not like '810%' rule 2 number like '810%' rule 3 number not like '8%' Вот нужные мне столбцы id, sum(number_rule1), sum(number_rule2), sum(number_rule3) Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.10.2002, 13:39:12 |
|
||
|
Ну очень хитрый запрос.
|
|||
|---|---|---|---|
|
#18+
Совсем тупо если, то select id, (select sum(number) from t2 where t1.id=t2.id and number like '8%' and not like '810%') as rule1, (select sum(number) from t2 where t1.id=t2.id and number like '810%') as rule2, (select sum(number) from t2 where t1.id=t2.id and number not like '8%') as rule3 from t1 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.10.2002, 13:40:45 |
|
||
|
Ну очень хитрый запрос.
|
|||
|---|---|---|---|
|
#18+
Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.10.2002, 13:43:44 |
|
||
|
Ну очень хитрый запрос.
|
|||
|---|---|---|---|
|
#18+
Тут что, конкурс - кто тупее!? :) Код: plaintext 1. 2. 3. 4. 5. 6. 7. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 23.10.2002, 13:49:40 |
|
||
|
|

start [/forum/topic.php?fid=46&gotonew=1&tid=1819386]: |
0ms |
get settings: |
7ms |
get forum list: |
10ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
27ms |
get topic data: |
8ms |
get first new msg: |
5ms |
get forum data: |
2ms |
get page messages: |
35ms |
get tp. blocked users: |
1ms |
| others: | 185ms |
| total: | 286ms |

| 0 / 0 |
