Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

why DISTINCT it is not working

Posted on 2014-10-20
4
Medium Priority
?
206 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 2000 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 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Suggested Courses

885 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