I’m trying to copy data from one table to another, while transposing it and combining it into appropriate rows, with different columns in the second table. First time posting. Yes this may seem …
Tag: sql
Count Male and Female in SQL and how many records are there. With male listed with their name
I have a table Company, and I want to group the entries by Male and Female. And I want their names listed in a column. The result should like as shown here: +——–+———-+——————-…
Update Primary Key Column Name in SQL
This code defines Category table in SQL: CREATE TABLE [dbo].[Categories] ( [CategoryID] INT IDENTITY (1, 1) NOT NULL, [Name] NVARCHAR(450) NULL, […
Get HIGHEST and SECOND HIGHEST value for each ID (SQL)
New to SQL. In Access 2016. In a table of different equipment (EQUIP1, EQUIP2, EQUIP3), I want in a query the last and second to last maintenance dates. Many fixes I have searched for do not account for grouping by an ID (EQUIP# in my case) What I have: What I need: EDIT: Thanks! Got a little caught up on
Replace 0 in one field in case statement result that is stringing fields
I have a statement like the following: select distinct s.field1, s.field 2, Case when s.intfield3 = 2018 then (RTRIM(cast(s.intfield4 as char (2))) +’/1/’+ cast(s.intfield3 as char (4))) when c….
Simulating NETWORKDAYS returns wrong business days
I created a NETWORKDAYS-like function on sql based on this solution wich returns correctly the business days while the records (BEG and END) are on business days. BEG END businessd —-…
Lead and case expression
I have this table: ID Date —————– 1 1/1/2019 1 1/15/2019 Expected output: ID DATE LEAD_DATE ————————- 1 1/1/2019 1/14/2019 1 1/15/2019 SYSDATE …
How to detect changes to values through a specific order
Given Id | RouteId | Milepoint | RoadCondition -: | :—— | ——–: | :———— 1 | A | 0 | X 2 | A | 1 | X 3 | A | 4 |…
Why is the AVG not returning anything in my Where clause in SQL?
The question ask, “List the customer name and phone number for customers whose credit limit is less than the average credit limit. (Customers table)” So far I have …
SQL round percent up to nearest .1
I have a columns of percentages and i want them to always round up to the nearest .1 for example .005 –> .1 .11 –> .2 .3256 –>.4 .6797 –>.7 I am trying ceiling and floor, but they …