These queries use the EC2 table created with [[AWS pricing tables in SQL#EC2]] ## How to get all the pricing data for a single instance type. Lot of columns are useless, the interesting part is in the **WHERE** clause. This query should return one and only one row. Use the WHERE clause to change instance type, region and other parameters. ```sql SELECT p1."SKU", p1."OfferTermCode", p1."RateCode", p1."TermType", p1."PriceDescription", p1."EffectiveDate", p1."StartingRange", p1."EndingRange", p1."Unit", p1."PricePerUnit", p1."Currency", p1."LeaseContractLength", p1."PurchaseOption", p1."OfferingClass", p1."Product Family", p1."serviceCode", p1."Location", p1."Location Type", p1."Instance Type", p1."Current Generation", p1."Instance Family", p1."vCPU", p1."Physical Processor", p1."Clock Speed", p1."Memory", p1."Storage", p1."Network Performance", p1."Processor Architecture", p1."Storage Media", p1."Volume Type", p1."Max Volume Size", p1."Max IOPS/volume", p1."Max IOPS Burst Performance", p1."Max throughput/volume", p1."Provisioned", p1."Tenancy", p1."EBS Optimized", p1."Operating System", p1."License Model", p1."Group", p1."Group Description", p1."Transfer Type", p1."From Location", p1."From Location Type", p1."To Location", p1."To Location Type", p1."usageType", p1.operation, p1."AvailabilityZone", p1."CapacityStatus", p1."ClassicNetworkingSupport", p1."Dedicated EBS Throughput", p1."ECU", p1."Elastic Graphics Type", p1."Enhanced Networking Supported", p1."From Region Code", p1."GPU", p1."GPU Memory", p1."Instance", p1."Instance Capacity - 10xlarge", p1."Instance Capacity - 12xlarge", p1."Instance Capacity - 16xlarge", p1."Instance Capacity - 18xlarge", p1."Instance Capacity - 24xlarge", p1."Instance Capacity - 2xlarge", p1."Instance Capacity - 32xlarge", p1."Instance Capacity - 4xlarge", p1."Instance Capacity - 8xlarge", p1."Instance Capacity - 9xlarge", p1."Instance Capacity - large", p1."Instance Capacity - medium", p1."Instance Capacity - metal", p1."Instance Capacity - xlarge", p1."instanceSKU", p1."Intel AVX Available", p1."Intel AVX2 Available", p1."Intel Turbo Available", p1."MarketOption", p1."Normalization Size Factor", p1."Physical Cores", p1."Pre Installed S/W", p1."Processor Features", p1."Product Type", p1."Region Code", p1."Resource Type", p1."serviceName", p1."SnapshotArchiveFeeType", p1."To Region Code", p1."Volume API Name", p1."VPCNetworkingSupport" FROM public.ec2_pricing p1 WHERE p1."TermType" = 'OnDemand' AND p1."Operating System" = 'Linux' AND p1."Tenancy" = 'Shared' AND p1."Region Code" = 'us-east-1' AND p1."Instance Type" = 't3.medium' AND p1."Pre Installed S/W" = 'NA' AND p1."CapacityStatus" = 'Used' ORDER BY "PricePerUnit" DESC ``` | SKU | OfferTermCode | RateCode | TermType | PriceDescription | EffectiveDate | StartingRange | EndingRange | Unit | PricePerUnit | Currency | LeaseContractLength | PurchaseOption | OfferingClass | Product Family | serviceCode | Location | Location Type | Instance Type | Current Generation | Instance Family | vCPU | Physical Processor | Clock Speed | Memory | Storage | Network Performance | Processor Architecture | Storage Media | Volume Type | Max Volume Size | Max IOPS/volume | Max IOPS Burst Performance | Max throughput/volume | Provisioned | Tenancy | EBS Optimized | Operating System | License Model | Group | Group Description | Transfer Type | From Location | From Location Type | To Location | To Location Type | usageType | operation | AvailabilityZone | CapacityStatus | ClassicNetworkingSupport | Dedicated EBS Throughput | ECU | Elastic Graphics Type | Enhanced Networking Supported | From Region Code | GPU | GPU Memory | Instance | Instance Capacity - 10xlarge | Instance Capacity - 12xlarge | Instance Capacity - 16xlarge | Instance Capacity - 18xlarge | Instance Capacity - 24xlarge | Instance Capacity - 2xlarge | Instance Capacity - 32xlarge | Instance Capacity - 4xlarge | Instance Capacity - 8xlarge | Instance Capacity - 9xlarge | Instance Capacity - large | Instance Capacity - medium | Instance Capacity - metal | Instance Capacity - xlarge | instanceSKU | Intel AVX Available | Intel AVX2 Available | Intel Turbo Available | MarketOption | Normalization Size Factor | Physical Cores | Pre Installed S/W | Processor Features | Product Type | Region Code | Resource Type | serviceName | SnapshotArchiveFeeType | To Region Code | Volume API Name | VPCNetworkingSupport | | ---------------- | ------------- | -------------------------------------- | -------- | --------------------------------------------------- | ------------- | ------------- | ----------- | ---- | ------------ | -------- | ------------------- | -------------- | ------------- | ---------------- | ----------- | --------------------- | ------------- | ------------- | ------------------ | --------------- | ---- | ------------------------ | ----------- | ------ | -------- | ------------------- | ---------------------- | ------------- | ----------- | --------------- | --------------- | -------------------------- | --------------------- | ----------- | ------- | ------------- | ---------------- | ------------------- | ----- | ----------------- | ------------- | ------------- | ------------------ | ----------- | ---------------- | ------------------ | ------------ | ---------------- | -------------- | ------------------------ | ------------------------ | -------- | --------------------- | ----------------------------- | ---------------- | ---- | ---------- | -------- | ---------------------------- | ---------------------------- | ---------------------------- | ---------------------------- | ---------------------------- | --------------------------- | ---------------------------- | --------------------------- | --------------------------- | --------------------------- | ------------------------- | -------------------------- | ------------------------- | -------------------------- | ----------- | ------------------- | -------------------- | --------------------- | ------------ | ------------------------- | -------------- | ----------------- | ----------------------------------------------------------- | ------------ | ----------- | ------------- | ---------------------------- | ---------------------- | -------------- | --------------- | -------------------- | | NN4EGUUQRWVYP98C | JRTCKXETXF | NN4EGUUQRWVYP98C.JRTCKXETXF.6YS6EN2CT7 | OnDemand | $0.0416 per On Demand Linux t3.medium Instance Hour | ######## | 0 | Inf | Hrs | 0.0416 | USD | NULL | NULL | NULL | Compute Instance | AmazonEC2 | US East (N. Virginia) | AWS Region | t3.medium | Yes | General purpose | 2 | Intel Skylake E5 2686 v5 | 3.1 GHz | 4 GiB | EBS only | Up to 5 Gigabit | 64-bit | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Shared | NULL | Linux | No License required | NULL | NULL | NULL | NULL | NULL | NULL | NULL | BoxUsage:t3.medium | RunInstances | NA | Used | FALSE | Up to 2085 Mbps | Variable | NULL | No | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Yes | Yes | Yes | OnDemand | 2 | NULL | NA | AVX; AVX2; Intel AVX; Intel AVX2; Intel AVX512; Intel Turbo | NULL | us-east-1 | NULL | Amazon Elastic Compute Cloud | NULL | NULL | NULL | TRUE |