..:: MX Studio Fóruns ::..: Função IIF em access!! - ..:: MX Studio Fóruns ::..

Jump to content

Publicidade




ATENÇÃO

Para evitar posts desnecessários e que não influam para o andamento e desenvolvimento do fórum, clique aqui e leia todas as regras.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Função IIF em access!! Como usar??

#1 User is offline   WMartins 

  • Group: Membros
  • Posts: 98
  • Joined: 10-February 06

  Posted 20 December 2006 - 12:55 PM

Galera, explicando minha ferramenta:

Tenho em sistema onde a pessoa escolhe alguns produtos e os cadastra em algum lugar, onde cada produto tem uma pontuação, só que dependendo do tipo de LICENÇA escolhida a pontuação será menor, ou seja:

Suponha que cadastrei o Produto "Photoshop" sua pontuação é 10 para qualquer tipo de licença EXCETO quando a licença for "Educacional" (IdLicense=7) a pontuação passa a ser 5.


Gostaria de iplantar um IIF que faça o seguinte:

SE tableSalesProducts.idLicense = 7, Sum((tableSalesProducts!quantity*tableProducts!pointsProduct)/2) AS pontos
SE NÃO Sum(tableSalesProducts!quantity*tableProducts!pointsProduct) AS pontos

como faria isso na query abaixo??

SELECT tableSalesmen.idSalesMan, Sum(tableSalesProducts!quantity*tableProducts!pointsProduct) AS pontos, Sum(tableSalesProducts!quantity*tableProducts!pointsProduct) AS saldo
FROM (tableSalesmen INNER JOIN tableSales ON tableSalesmen.idSalesMan=tableSales.idSalesman) INNER JOIN (tableProducts INNER JOIN tableSalesProducts ON tableProducts.idProduct=tableSalesProducts.idProduct) ON tableSales.idSale=tableSalesProducts.idSale
GROUP BY tableSalesmen.idSalesMan, tableSales.closing, tableSales.bkp01
HAVING (((tableSales.closing)=True) AND ((tableSales.bkp01)=True));

Valeu
0

#2 User is offline   pcsilva 

  • Group: Moderadores
  • Posts: 1940
  • Joined: 23-January 05

Posted 20 December 2006 - 01:12 PM

http://msdn2.microsoft.com/en-us/library/ms181765.aspx

Não testei, testa ai.

CODE
SELECT tableSalesmen.idSalesMan,
pontos =
    CASE tableSalesProducts.idLicense WHEN 7 THEN Sum((tableSalesProducts.quantity*tableProducts.pointsProduct)/2)
        ELSE Sum(tableSalesProducts.quantity*tableProducts.pointsProduct)
    END
, Sum(tableSalesProducts!quantity*tableProducts!pointsProduct) AS saldo
FROM (tableSalesmen INNER JOIN tableSales ON tableSalesmen.idSalesMan=tableSales.idSalesman) INNER JOIN (tableProducts INNER JOIN tableSalesProducts ON tableProducts.idProduct=tableSalesProducts.idProduct) ON tableSales.idSale=tableSalesProducts.idSale
GROUP BY tableSalesmen.idSalesMan, tableSales.closing, tableSales.bkp01
HAVING (((tableSales.closing)=True) AND ((tableSales.bkp01)=True));

0

#3 User is offline   pcsilva 

  • Group: Moderadores
  • Posts: 1940
  • Joined: 23-January 05

Posted 20 December 2006 - 01:16 PM

HI! é no access, mandei uma resposta para SQL Server.

Vai ai a pagina certa para Access.
lembra que no access tem aquela maluquice de ! para referenciar tabela.

http://support.microsoft.com/kb/209192
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


Similar Topics Collapse

  Topic Forum Started By Stats Last Post Info
New Replies Redimensionamento de Imagem
Alguém sabe qual função usar???
PHP Lucas Oliveira 
  • 1 Reply
  • 534 Views
New Replies Como posso Criar
Mercado livre
Dreamweaver mattheusp 
  • 1 Reply
  • 580 Views
New Replies Anexo junto ao Formmail
como faço para enviar anexo ao formulário
PHP ricardoelias 
  • 1 Reply
  • 947 Views
New Replies RDS não funciona!
Como resolvo esse problema?
ColdFusion frettarenan 
  • 13 Replies
  • 2333 Views
New Replies Menu Flash fica reiniciando
Como não reiniciar a animação a cada troca de página?
Flash & ActionScript rcosta 
  • 1 Reply
  • 787 Views
New Replies Selecionar dinamicamente um item no combo
como fazer isso..?
Flash & ActionScript Mentell 
  • 1 Reply
  • 523 Views
New Replies .exe
como remover barras
Flash & ActionScript scorpion_hs_ 
  • 4 Replies
  • 1413 Views
New Replies Como eu faço um album de fotos
Album de fotos que tem miniaturas e quando clico ela abre numa pop up
PHP Lordouglas 
  • 6 Replies
  • 2751 Views

Publicidade




1 User(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)