Solved

why DISTINCT it is not working

Posted on 2014-10-20
4
181 Views
Last Modified: 2014-10-20
Por que no funciona el distinct
SELECT DISTINCT G.IDGERENCIA, GS.AREA
  FROM TA_GASTOS_STAGE GS
       INNER JOIN TA_GERENCIA G ON GS.GERENCIA_DIRECCIÓN = G.NOMBREGERENCIA
WHERE
       GS.AREA LIKE '%Mantenimiento Palmas%'  
ORDER BY G.IDGERENCIA,GS.AREA

         IDGERENCIA      AREA
1      11      Mantenimiento Palmas
2      11      Mantenimiento Palmas

this is the table_stage
SELECT *
  FROM TA_GASTOS_STAGE GS
WHERE
       GS.AREA LIKE '%Mantenimiento Palmas%'  
         TIPO      CECO      DESCRIPCION_CECO      F4      GERENCIA_DIRECCIÓN      AREA      PLANTA      RESPONSABLE      F9      F10      F11      F12      F13      F14      F15      F16
1      Producción      10P30803      Soplado Palmas Supervisión Mantenimiento            Gerencia Producción Soplado      Mantenimiento Palmas       Palmas                                                      
2      Producción      10P30804      Soplado Palmas  Mantenimiento            Gerencia Producción Soplado      Mantenimiento Palmas      Palmas
0
Comment
Question by:enrique_aeo
  • 3
4 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 40392676
you probably have white space in the columns you can't see
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 500 total points
ID: 40392677
try this to see if you have extra invisible white space


SELECT DISTINCT G.IDGERENCIA, GS.AREA, length(gs.area)
  FROM TA_GASTOS_STAGE GS
       INNER JOIN TA_GERENCIA G ON GS.GERENCIA_DIRECCIÓN = G.NOMBREGERENCIA
WHERE
       GS.AREA LIKE '%Mantenimiento Palmas%'  
ORDER BY G.IDGERENCIA,GS.AREA
0
 

Author Comment

by:enrique_aeo
ID: 40392687
i agree

1      11      Mantenimiento Palmas      20
2      11      Mantenimiento Palmas       21

As I can do an UPDATE to remove blanks?
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 500 total points
ID: 40392689
try this...


update  TA_GASTOS_STAGE set area = trim(area)

or, to only remove trailing blanks

update  TA_GASTOS_STAGE set area = rtrim(area)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question