Pergunta

This is the script I have. I have to have all fields selected but only have to show PartNumber and PartDesc.

SELECT UPPER (PartNumber) AS “Part Number”,
       UPPER (Partdesc) AS “Part Description”,
                             UnitsOnHand,
                             ItemClass,
                             Warehouse, 
                             UnitPrice                   
FROM Part

ORDER BY Warehouse DESC,
         UnitPrice ASC; 

I am learning this for uni and am not 100% with it but am trying to learn.

Foi útil?

Solução

Literally your question is converted into below SQL, where I select all columns in the sub query and show only two

SELECT part_number, 
       part_description 
FROM   (SELECT Upper (partnumber) AS Part_Number, 
               INITCAP (partdesc)   AS Part_Description, 
               unitsonhand, 
               itemclass, 
               warehouse, 
               unitprice 
        FROM   part 
        ORDER  BY warehouse DESC, 
                  unitprice ASC); 

Best Option is to do

SELECT Upper (partnumber) AS Part_Number, 
       Initcap (partdesc)   AS Part_Description 
FROM   part 
ORDER  BY warehouse DESC, 
          unitprice ASC; 

Or even you can have a view

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top