-
Total de itens
11 -
Registro em
-
Última visita
Tudo que Mactos Cohen postou
-
selecionar ultimo [Resolvido] Selecionar último registo de cada cliente
Mactos Cohen respondeu ao tópico de Mactos Cohen em MySQL
Muito Obrigado Motta funcionou sim, apenas acrescentei GROUP BY cliente_cxm SELECT tb1.* from tb_mov_caixa tb1 where designacao_cxm = 'Pagamento' and data_cxm = (SELECT MAX(tb2.data_cxm) from tb_mov_caixa tb2 where tb2.designacao_cxm = tb1.designacao_cxm and tb2.cliente_cxm = tb1.cliente_cxm) GROUP BY cliente_cxm -
selecionar ultimo [Resolvido] Selecionar último registo de cada cliente
Mactos Cohen postou um tópico no fórum MySQL
Ola Galera tudo bem... estou com dificuldades em pegar o último registo de cada cliente, tentei com essa query mais so pega o último id de cada cliente o resto pega o primeiro. por favor SELECT MAX(id_cxm), mes_cxm, cliente_cxm from tb_mov_caixa where designacao_cxm = 'Pagamento' GROUP BY cliente_cxm -
selecionar ultimo [Resolvido] Selecionar último registo de cada cliente
Mactos Cohen respondeu ao tópico de Mactos Cohen em MySQL
Ola Motta, muito obrigado mas continuo com duvidas no seguinte: tabela t2 qual seria na minha db? e data? select * from tabela t1 where data = (select max(data) from tabela t2 where t2.id = t1.id) -
Ola Galera beleza... Quero exibir uma pauta de notas por disciplinas, mas estou com dificuldade, quero fazer algo assim como esta no excel. por favor quem tiver uma ideia <td width="23" rowspan="2" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>Nº</strong></td> <td width="379" rowspan="2" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>Nome</strong></td> <td colspan="3">Português</td> <td colspan="3" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif">Inglês</td> <td colspan="3" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif">Educação Física</td> <td width="12" colspan="3" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif">Matemática</td> <td colspan="3" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif">Biologia</td> <td colspan="3" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif">Química</td> <td width="12" colspan="3" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif">Psicologia Geral</td> <td width="13" colspan="3" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif">Microbiologia Clínica</td> <td width="27" colspan="3" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif">Hematologia</td> <td width="27" colspan="3" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif">Imunologia</td> <td width="27" colspan="3" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif">Bioquímica</td> <td width="27" colspan="3" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif">Urinologia</td> <td rowspan="2" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>OBSERVAÇÃO</strong></td> <td width="22" rowspan="2" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>Nº</strong></td> </tr> <tr> <td width="34" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Just.</strong></td> <td width="33" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Injust</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>CF1</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Just.</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Injust</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>CF1</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Just.</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Injust</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>CF1</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Just.</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Injust</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>CF1</strong></td> <td width="13" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Just.</strong></td> <td width="27" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Injust</strong></td> <td width="27" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>CF1</strong></td> <td width="27" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Just.</strong></td> <td width="27" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Injust</strong></td> <td width="27" align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>CF1</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Just.</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Injust</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>CF1</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Just.</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Injust</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>CF1</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Just.</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Injust</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>CF1</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Just.</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Injust</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>CF1</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Just.</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Injust</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>CF1</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Just.</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>F. Injust</strong></td> <td align="center" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"><strong>CF1</strong></td> </tr> </thead> <tbody> <?php $sql_notas = mysql_query("SELECT id_aluno, nome_aluno, ano_lectivo, data_pagamento_m, nome_classe, codigo_classe, nome_curso, valor_curso1, multa, contacto, MAC1, MAC2, MAC3, PP1, PP2, PP21, PP22, PP31, PP32, PG FROM tb_matriculas INNER JOIN tb_classe ON tb_matriculas.classe = tb_classe.id_classe INNER JOIN tb_curso ON tb_curso.codigo_curso = tb_matriculas.curso INNER JOIN tb_notas ON tb_matriculas.id_aluno = tb_notas.id_aluno_nota WHERE curso_nota = '$curso1' AND classe_nota = '$classe1' AND periodo_nota = '$periodo1' AND turma_nota = '$turma1' AND ano_nota = '$ano_select' ") or die(mysql_error()); $contar = mysql_num_rows( $sql_notas); $i = 1; while ($resultado = mysql_fetch_array($sql_notas, MYSQL_ASSOC)){ $id_aluno = $resultado ['id_aluno']; $nome_aluno = $resultado ['nome_aluno']; $classe_aluno = $resultado ['nome_classe']; $classe_codigo = $resultado ['codigo_classe']; $valor = $resultado ['valor_curso1']; $curso = $resultado ['nome_curso']; $telefone = $resultado ['contacto']; $data_pagamento = $resultado ['data_pagamento_m']; $ano = $resultado ['ano_lectivo']; $MAC1 = $resultado ['MAC1']; $pp1 = $resultado ['PP1']; $pp21 = $resultado ['PP21']; $pp22 = $resultado ['PP22']; $pp31 = $resultado ['PP31']; $pp31 = $resultado ['PP31']; $pp2 = $resultado ['PP2']; $MAC2 = $resultado ['MAC2']; $MAC3 = $resultado ['MAC3']; $PG = $resultado ['PG']; $mes_pagamento = $resultado ['data_pagamento_m']; ?> <tr class="<?php echo ($i % 2) == 1 ? 'linha_a' : 'linha_b'?>"> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif" ><span style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; color: #000B88;"><?php echo $i?></span></td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif" ><?php echo $nome_aluno?></td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($MAC1 <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($pp1 <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?>"> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($pp2 <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($MAC2 <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($pp21 <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($pp22 <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($MAC3 <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($pp31 <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif"> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; <?php if ($PG <= 9.9){echo 'color: #FF060A';} else {echo 'color: #000B88';} ?> "> </td> <td align="right" style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif" ><span style="font-family: Segoe, 'Segoe UI', 'DejaVu Sans', 'Trebuchet MS', Verdana, sans-serif; color: #000B88;"><?php echo $i?></span></td>