SlideShare una empresa de Scribd logo
SQL Server - Problemas para seleccionar
registros con SELECT
Volver
Agregar Nota
<<>>
Vista:
Problemas para seleccionar registros con SELECT
Omar (21/05/2013 23:09:27)407 visitas
4 respuestas
Problemas para seleccionar registros con SELECT
xve (22/05/2013 07:44:03)
Problemas para seleccionar registros con SELECT
Omar (22/05/2013 20:10:08)
Problemas para seleccionar registros con SELECT
xve (22/05/2013 22:56:19)
Problemas para seleccionar registros con SELECT
Omar (23/05/2013 20:32:09)
0
As
un
to:
Problemas para
seleccionar
registros con
SELECT
Au
tor
:
Omar omar_po
nce2001@hotm
ail.com (3
intervenciones)
Fe
ch
a:
21/05/2013
23:09:27
Tengo una tabla de movimientos de facturas emitidas y pagos, puede haber varios
movimientos por cada factura sobre todo por pagos parciales.La emision de la factura va en
la columna debe y los pagos al haber, la suma de debe-haber me informa si la factura esta
cancelada o no.
Necesito mediante una select generar todas las facturas de un cliente que tengan saldo
pendiente
(es decir la suma de debe-haber diferente de 0) por cada factura del cliente.
Arme esta select que funciona pero solo muestra el saldo de la factura, necesito me muestre
todos los movimientos parciales que generan ese saldo.
SELECT nrofac,SUM(debe-haber) AS Total ;
FROM c_mov ;
WHERE nrocli = 10191 ;
GROUP BY nrofac ;
HAVING SUM(debe-haber) <> 0
Ojala me haya expresado bien, y muchas gracias de antemano por la atencion
Responder
Otras secciones de LWP con contenido similar...
- Cursos de SQL Server
- Temas de SQL Server
0
As
unt
o:
Proble
mas
para
selecc
ionar
registr
os con
SELE
CT
Au
tor
:
xve (2
9
interv
encion
es)
Fe
ch
a:
22/05/
2013
07:44:
03
Hola Omar, creo que asín te puede funcionar:
SELECT * FROM c_mov LEFT JOIN ( SELECT nrofac,SUM(debe-haber) AS Total ;
FROM c_mov ; WHERE nrocli = 10191 ; GROUP BY nrofac ; HAVING SUM(debe-
haber) <> 0 ) S1 ON c_mov.nrofac=S1.nrofac
Coméntanos, ok?
Comentar
0
As
un
to:
Problemas para
seleccionar
registros con
SELECT
Au
tor
:
Omar omar_po
nce2001@hotm
ail.com (3
intervenciones)
Fe
ch
a:
22/05/2013
20:10:08
Estimado xve, muchas gracias por tu amable y pronta respuesta
Probé la sentencia que me aconsejaste en una tabla de prueba y en principio funciona bien,
hace la sumatoria de los saldos por factura, el problema es que no hace la seleccion del
cliente especificado sino que me trae todos y ademas como en la columna total aparece el
valor NULL en lugar de ceros para las facturas canceladas tambien los trae, no es lo que
necesito pero por lo menos tengo identificados aquellos registros que sirven.
Voy a seguir intentando, sino agradeceria tu inestimable ayuda
Un abrazo
Comentar
0
As
unt
o:
Proble
mas
para
selecc
ionar
registr
os con
SELE
CT
Au
tor
:
xve (2
9
interv
encion
es)
Fe
ch
a:
22/05/
2013
22:56:
19
Hola Omar, perdon, tienes razón, tendrias que hacer el where fuera...algo así:
SELECT * FROM c_mov LEFT JOIN ( SELECT nrofac,SUM(debe-haber) AS Total ;
FROM c_mov ; GROUP BY nrofac ; HAVING SUM(debe-haber) <> 0 ) S1 ON
c_mov.nrofac=S1.nrofac WHERE c.nrocli = 10191 ;
Coméntanos, ok?
Comentar
0
As
unt
o:
Proble
mas
para
selecc
ionar
registr
os con
SELE
CT
Au
tor
:
Omar
(3
interv
encion
es)
Fe
ch
a:
23/05/
2013
20:32:
09
Gracias xve, problema solucionado, solamente me muestra algunos registros con total
NULL, pero es un tema menor y facilmente solucionable.
Nuevamente muchas gracias por tu amabilidad
Un abrazo

Más contenido relacionado

Último

TAREA DE TECNOLOGIA DE LA FICHHA 1 Y DOS
TAREA DE TECNOLOGIA DE LA FICHHA 1 Y DOSTAREA DE TECNOLOGIA DE LA FICHHA 1 Y DOS
TAREA DE TECNOLOGIA DE LA FICHHA 1 Y DOS
darlingreserved
 
TECLADO ERGONÓMICO Y PANTALLAS TACTILES.
TECLADO ERGONÓMICO Y PANTALLAS TACTILES.TECLADO ERGONÓMICO Y PANTALLAS TACTILES.
TECLADO ERGONÓMICO Y PANTALLAS TACTILES.
FransuaPeralta
 
Presentación- PLATAFORMA VIRTUAL E-LEARNING .pptx
Presentación-  PLATAFORMA VIRTUAL E-LEARNING .pptxPresentación-  PLATAFORMA VIRTUAL E-LEARNING .pptx
Presentación- PLATAFORMA VIRTUAL E-LEARNING .pptx
arelisguerra707
 
Las plantas ornamental su importancia, sus variedades etc
Las plantas ornamental su importancia, sus variedades etcLas plantas ornamental su importancia, sus variedades etc
Las plantas ornamental su importancia, sus variedades etc
60475271
 
Solucionario 5° P2P16.pptxihiuhiuhihihini
Solucionario 5° P2P16.pptxihiuhiuhihihiniSolucionario 5° P2P16.pptxihiuhiuhihihini
Solucionario 5° P2P16.pptxihiuhiuhihihini
corderojulia187
 
MODELO PEDAG DE LA FPI SENA PARA LA FORMACION PROFESIONAL E INTEGRAL
MODELO PEDAG DE LA FPI SENA PARA LA FORMACION PROFESIONAL E INTEGRALMODELO PEDAG DE LA FPI SENA PARA LA FORMACION PROFESIONAL E INTEGRAL
MODELO PEDAG DE LA FPI SENA PARA LA FORMACION PROFESIONAL E INTEGRAL
Fernando540828
 
QUÉ ES ALARA proteccion rayografica.pptx
QUÉ ES ALARA proteccion rayografica.pptxQUÉ ES ALARA proteccion rayografica.pptx
QUÉ ES ALARA proteccion rayografica.pptx
AnthonyFernandoArias
 
TRABAJO DE TECNOLOGIA increíble y próspero epico
TRABAJO DE TECNOLOGIA increíble y próspero epicoTRABAJO DE TECNOLOGIA increíble y próspero epico
TRABAJO DE TECNOLOGIA increíble y próspero epico
edepjuanorozco
 

Último (8)

TAREA DE TECNOLOGIA DE LA FICHHA 1 Y DOS
TAREA DE TECNOLOGIA DE LA FICHHA 1 Y DOSTAREA DE TECNOLOGIA DE LA FICHHA 1 Y DOS
TAREA DE TECNOLOGIA DE LA FICHHA 1 Y DOS
 
TECLADO ERGONÓMICO Y PANTALLAS TACTILES.
TECLADO ERGONÓMICO Y PANTALLAS TACTILES.TECLADO ERGONÓMICO Y PANTALLAS TACTILES.
TECLADO ERGONÓMICO Y PANTALLAS TACTILES.
 
Presentación- PLATAFORMA VIRTUAL E-LEARNING .pptx
Presentación-  PLATAFORMA VIRTUAL E-LEARNING .pptxPresentación-  PLATAFORMA VIRTUAL E-LEARNING .pptx
Presentación- PLATAFORMA VIRTUAL E-LEARNING .pptx
 
Las plantas ornamental su importancia, sus variedades etc
Las plantas ornamental su importancia, sus variedades etcLas plantas ornamental su importancia, sus variedades etc
Las plantas ornamental su importancia, sus variedades etc
 
Solucionario 5° P2P16.pptxihiuhiuhihihini
Solucionario 5° P2P16.pptxihiuhiuhihihiniSolucionario 5° P2P16.pptxihiuhiuhihihini
Solucionario 5° P2P16.pptxihiuhiuhihihini
 
MODELO PEDAG DE LA FPI SENA PARA LA FORMACION PROFESIONAL E INTEGRAL
MODELO PEDAG DE LA FPI SENA PARA LA FORMACION PROFESIONAL E INTEGRALMODELO PEDAG DE LA FPI SENA PARA LA FORMACION PROFESIONAL E INTEGRAL
MODELO PEDAG DE LA FPI SENA PARA LA FORMACION PROFESIONAL E INTEGRAL
 
QUÉ ES ALARA proteccion rayografica.pptx
QUÉ ES ALARA proteccion rayografica.pptxQUÉ ES ALARA proteccion rayografica.pptx
QUÉ ES ALARA proteccion rayografica.pptx
 
TRABAJO DE TECNOLOGIA increíble y próspero epico
TRABAJO DE TECNOLOGIA increíble y próspero epicoTRABAJO DE TECNOLOGIA increíble y próspero epico
TRABAJO DE TECNOLOGIA increíble y próspero epico
 

Destacado

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
 

Destacado (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Resolucion de problema de sql

  • 1. SQL Server - Problemas para seleccionar registros con SELECT Volver Agregar Nota <<>> Vista: Problemas para seleccionar registros con SELECT Omar (21/05/2013 23:09:27)407 visitas 4 respuestas Problemas para seleccionar registros con SELECT xve (22/05/2013 07:44:03) Problemas para seleccionar registros con SELECT Omar (22/05/2013 20:10:08)
  • 2. Problemas para seleccionar registros con SELECT xve (22/05/2013 22:56:19) Problemas para seleccionar registros con SELECT Omar (23/05/2013 20:32:09) 0 As un to: Problemas para seleccionar registros con SELECT Au tor : Omar omar_po nce2001@hotm ail.com (3 intervenciones) Fe ch a: 21/05/2013 23:09:27 Tengo una tabla de movimientos de facturas emitidas y pagos, puede haber varios movimientos por cada factura sobre todo por pagos parciales.La emision de la factura va en la columna debe y los pagos al haber, la suma de debe-haber me informa si la factura esta cancelada o no. Necesito mediante una select generar todas las facturas de un cliente que tengan saldo pendiente (es decir la suma de debe-haber diferente de 0) por cada factura del cliente. Arme esta select que funciona pero solo muestra el saldo de la factura, necesito me muestre todos los movimientos parciales que generan ese saldo. SELECT nrofac,SUM(debe-haber) AS Total ; FROM c_mov ; WHERE nrocli = 10191 ; GROUP BY nrofac ; HAVING SUM(debe-haber) <> 0 Ojala me haya expresado bien, y muchas gracias de antemano por la atencion
  • 3. Responder Otras secciones de LWP con contenido similar... - Cursos de SQL Server - Temas de SQL Server 0 As unt o: Proble mas para selecc ionar registr os con SELE CT Au tor : xve (2 9 interv encion es) Fe ch a: 22/05/ 2013 07:44: 03 Hola Omar, creo que asín te puede funcionar: SELECT * FROM c_mov LEFT JOIN ( SELECT nrofac,SUM(debe-haber) AS Total ; FROM c_mov ; WHERE nrocli = 10191 ; GROUP BY nrofac ; HAVING SUM(debe- haber) <> 0 ) S1 ON c_mov.nrofac=S1.nrofac Coméntanos, ok?
  • 4. Comentar 0 As un to: Problemas para seleccionar registros con SELECT Au tor : Omar omar_po nce2001@hotm ail.com (3 intervenciones) Fe ch a: 22/05/2013 20:10:08 Estimado xve, muchas gracias por tu amable y pronta respuesta Probé la sentencia que me aconsejaste en una tabla de prueba y en principio funciona bien, hace la sumatoria de los saldos por factura, el problema es que no hace la seleccion del cliente especificado sino que me trae todos y ademas como en la columna total aparece el valor NULL en lugar de ceros para las facturas canceladas tambien los trae, no es lo que necesito pero por lo menos tengo identificados aquellos registros que sirven. Voy a seguir intentando, sino agradeceria tu inestimable ayuda Un abrazo Comentar 0 As unt o: Proble mas para selecc
  • 5. ionar registr os con SELE CT Au tor : xve (2 9 interv encion es) Fe ch a: 22/05/ 2013 22:56: 19 Hola Omar, perdon, tienes razón, tendrias que hacer el where fuera...algo así: SELECT * FROM c_mov LEFT JOIN ( SELECT nrofac,SUM(debe-haber) AS Total ; FROM c_mov ; GROUP BY nrofac ; HAVING SUM(debe-haber) <> 0 ) S1 ON c_mov.nrofac=S1.nrofac WHERE c.nrocli = 10191 ; Coméntanos, ok? Comentar 0 As unt o: Proble mas para selecc ionar registr os con SELE CT Au tor : Omar (3 interv encion es) Fe ch a: 23/05/ 2013 20:32: 09 Gracias xve, problema solucionado, solamente me muestra algunos registros con total NULL, pero es un tema menor y facilmente solucionable.
  • 6. Nuevamente muchas gracias por tu amabilidad Un abrazo