Access SQL Examples

SELECT Tree.ItemName, Vendor.VendorNo, Vendor.Company, Vendor.Contact
FROM Vendor INNER JOIN Tree ON Vendor.VendorNo = Tree.VendorNo;

SELECT Tree.ItemNo, Tree.ItemName, Tree.OnHand, Tree.OnOrder, Tree.ReorderPt
FROM Tree
WHERE ((([Tree]![OnHand]+[Tree]![OnOrder])<[Tree]![ReorderPt]));

SELECT Tree.ItemNo, Tree.ItemName, Tree.OnHand, Tree.OnOrder
FROM Tree
WHERE (((Tree.OnHand)>10) AND ((Tree.OnOrder)>10));

SELECT Tree.ItemNo, Tree.ItemName, Tree.OnHand, Tree.OnOrder, Tree.Price
FROM Tree
WHERE (((Tree.OnOrder)>10) AND ((Tree.Price)>50)) OR (((Tree.OnHand)>10) AND ((Tree.Price)>50));

SELECT Tree.ItemNo, Tree.ItemName, Tree.OnHand, Tree.OnOrder, Tree.ReorderPt
FROM Tree
WHERE ((([OnHand]+[OnOrder])<[ReorderPt]));

SELECT Tree.ItemNo, Tree.ItemName, Tree.Cost, Tree.Price
FROM Tree
WHERE (([Tree]![Price]>[Tree]![Cost]*1.25));

SELECT Tree.ItemNo, Tree.ItemName, Tree.OnHand, Tree.OnOrder, Tree.ReorderPt
FROM Tree
WHERE (([OnHand]+[OnOrder]<[ReorderPt]));

SELECT Tree.ItemNo, Tree.ItemName, Tree.OnHand, Tree.OnOrder
FROM Tree
WHERE (((Tree.ItemName)>"L"));

SELECT Tree.ItemNo, Tree.ItemName, Tree.OnHand, Tree.OnOrder
FROM Tree
WHERE (((Tree.OnHand)>10)) OR (((Tree.OnOrder)>10));

SELECT Tree.ItemNo, Tree.ItemName, Tree.Cost, Tree.Price, Tree.ReorderPt
FROM Tree
WHERE (((Tree.Price)>75))
ORDER BY Tree.Price;

SELECT Tree.ItemName, Tree.OnHand, Tree.OnOrder, Tree.ReorderPt, Tree.Cost
FROM Tree
WHERE (([Tree]![OnHand]+[Tree]![OnOrder]<[Tree]![ReorderPt] And [Tree]![Cost]>50));

SELECT [ItemNo], [ItemName], [OnHand], [OnOrder]
FROM Tree;

SELECT Tree.ItemNo, Tree.ItemName, Tree.Price
FROM Tree
WHERE (((Tree.Price)>100));

SELECT empid, emplname, empfname, emptype
FROM pay
WHERE emptype="S";

SELECT pay.empid, pay.emptype, pay.empdept, pay.empfname, pay.emplname, pay.empadr, pay.empcity, pay.empstate, pay.empzip, pay.empsalary, pay.emppayhr, pay.emphrs
FROM pay
WHERE (((pay.emptype)="S"));

SELECT pay.empid, pay.emptype, pay.empdept, [emplname]+","+[pay]![empfname] AS name, pay.empsalary AS salary, [pay]![emppayhr]*[pay]![emphrs]*52 AS appx_pay
FROM pay
WHERE (((pay.empdept)="12") AND ((pay.empsalary)>40000)) OR (((pay.empdept)="12") AND (([pay]![emppayhr]*[pay]![emphrs]*52)>40000));


SELECT pay.empid AS id, pay.emptype AS type, pay.empdept AS dept, [emplname]+", "+[pay]![empfname] AS name, pay.emppayhr AS [pay/hr], pay.emphrs AS hours, [pay]![emppayhr]*[pay]![emphrs] AS pay
FROM pay
WHERE (((pay.emptype)="H" Or (pay.emptype)="P"));