SlideShare una empresa de Scribd logo
1 de 6
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

La busqueda de la relevancia en la economia (Harberger).pptx
La busqueda de la relevancia en la economia (Harberger).pptxLa busqueda de la relevancia en la economia (Harberger).pptx
La busqueda de la relevancia en la economia (Harberger).pptxPEPONLU
 
477407774-EMBRIOLOGIA-DEL-SISTEMA-NERVIOSO.pptx
477407774-EMBRIOLOGIA-DEL-SISTEMA-NERVIOSO.pptx477407774-EMBRIOLOGIA-DEL-SISTEMA-NERVIOSO.pptx
477407774-EMBRIOLOGIA-DEL-SISTEMA-NERVIOSO.pptxAndreaSoto281274
 
PRESENTACION SISTEMAS OPERATIVOS MOVILES_20240424_235225_0000.pdf
PRESENTACION SISTEMAS OPERATIVOS MOVILES_20240424_235225_0000.pdfPRESENTACION SISTEMAS OPERATIVOS MOVILES_20240424_235225_0000.pdf
PRESENTACION SISTEMAS OPERATIVOS MOVILES_20240424_235225_0000.pdfSuleimaJimnez
 
Vision de asignatura ESTRUCTURA DE DATOS.pptx
Vision de asignatura ESTRUCTURA DE DATOS.pptxVision de asignatura ESTRUCTURA DE DATOS.pptx
Vision de asignatura ESTRUCTURA DE DATOS.pptxjmatheus74
 
Mapa conceptual de el hardware y software
Mapa conceptual de el hardware y softwareMapa conceptual de el hardware y software
Mapa conceptual de el hardware y softwarejorgeadrianoropezame
 
HIDRAULICA PRINCIPIOS FISICOS , LEY DE PASCAL Y FUNDAMENTOS video.pptx
HIDRAULICA PRINCIPIOS FISICOS , LEY DE PASCAL Y FUNDAMENTOS video.pptxHIDRAULICA PRINCIPIOS FISICOS , LEY DE PASCAL Y FUNDAMENTOS video.pptx
HIDRAULICA PRINCIPIOS FISICOS , LEY DE PASCAL Y FUNDAMENTOS video.pptxFranckRussellFlorGue
 

Último (6)

La busqueda de la relevancia en la economia (Harberger).pptx
La busqueda de la relevancia en la economia (Harberger).pptxLa busqueda de la relevancia en la economia (Harberger).pptx
La busqueda de la relevancia en la economia (Harberger).pptx
 
477407774-EMBRIOLOGIA-DEL-SISTEMA-NERVIOSO.pptx
477407774-EMBRIOLOGIA-DEL-SISTEMA-NERVIOSO.pptx477407774-EMBRIOLOGIA-DEL-SISTEMA-NERVIOSO.pptx
477407774-EMBRIOLOGIA-DEL-SISTEMA-NERVIOSO.pptx
 
PRESENTACION SISTEMAS OPERATIVOS MOVILES_20240424_235225_0000.pdf
PRESENTACION SISTEMAS OPERATIVOS MOVILES_20240424_235225_0000.pdfPRESENTACION SISTEMAS OPERATIVOS MOVILES_20240424_235225_0000.pdf
PRESENTACION SISTEMAS OPERATIVOS MOVILES_20240424_235225_0000.pdf
 
Vision de asignatura ESTRUCTURA DE DATOS.pptx
Vision de asignatura ESTRUCTURA DE DATOS.pptxVision de asignatura ESTRUCTURA DE DATOS.pptx
Vision de asignatura ESTRUCTURA DE DATOS.pptx
 
Mapa conceptual de el hardware y software
Mapa conceptual de el hardware y softwareMapa conceptual de el hardware y software
Mapa conceptual de el hardware y software
 
HIDRAULICA PRINCIPIOS FISICOS , LEY DE PASCAL Y FUNDAMENTOS video.pptx
HIDRAULICA PRINCIPIOS FISICOS , LEY DE PASCAL Y FUNDAMENTOS video.pptxHIDRAULICA PRINCIPIOS FISICOS , LEY DE PASCAL Y FUNDAMENTOS video.pptx
HIDRAULICA PRINCIPIOS FISICOS , LEY DE PASCAL Y FUNDAMENTOS video.pptx
 

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 HealthThinkNow
 
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.pdfmarketingartwork
 
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 2024Neil 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 2024Albert 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 InsightsKurio // 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 2024Search 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 summarySpeakerHub
 
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 IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit 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 managementMindGenius
 
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 WorkGetSmarter
 

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