문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top