I don't write a ton of functions, but this one has me stumped.
-- =============================================
alter FUNCTION rptContractInvoiceLineTax
(
@InvoiceLineAmount money,
@TaxAreaID smallint,
@TaxGroupID smallint
)
RETURNS money
AS
BEGIN
--set NOCOUNT off
DECLARE...
If possible, I'd like to calculate the differences between every two rows (bold rows to be added):
9/2022 1000
9/2021 900
Variance 100
10/2022 1000
10/2021 1200
Variance (200)
I'm guessing I would use lead/lag and some kind of loop, but if anyone has something...
Dataset looks like this:
Account OrderDate
100 5/1/2020
100 5/5/2020
100 6/1/2020
200 6/1/2020
200 6/2/2020
200 6/7/2020
I need the first order only, plus the order date of the next order, and discard the other records:
Account...
I have a job scheduled via SQL Server Agent that has been running successfully every 15 minutes for many months. Today a user alerted me that the resulting data seemed stale, and when I looked in the job history the most recent instance was several hours ago. There was no stop date on the job...
I have data in columns such as this:
Dept. Date Revenue
1000 2/1/2019 $1000
1000 2/2/2019 $2000
1000 2/3/2019 $3000
1001 2/1/2019 $4000
1001 2/2/2019 $5000
1001 2/3/2019 $6000
I need to be able to look up the department number and return all...
I have a table of surgical procedures:
Account [tab] ProcedureCode
999 [tab][tab][tab]X1235
And a table used to cross reference procedures to billing codes:
RangeStart [tab][tab][tab] RangeEnd
X1234 [tab][tab][tab] [tab][tab][tab] X1345
X2345...
I have a group of patients participating in a special program. I need to compute the number of hospital visits for each patient before and after they joined this program.
Patient table looks like this:
PatientID ActiveDate InactiveDate PreActiveVisits
111...
I have working code that splits values into a variable table:
I need to take the first two values, determine if the StringValues match, and if so pass both strings from the Value field as input parameters to another SP. If the StringValues don't match then ignore.
Then take values 2 and 3...
I have a recordset in a temp table that contains records like these (in addition to many other records that I want to keep):
Account EffectiveDate SequenceID UndoneDateTime UndoneSequenceID
9999 1/1/2016 13:00 4
9999 1/1/2016 13:00 8...
I have a fairly simple query that runs in a few seconds - similar to this:
select
patient,
room,
max(intime) as InTime,
OpDateTime
from some tables
group by patient, room, OpDateTime
where OpDateTime is not null
However, when changing to
where OpDateTime is null
then the query takes ten...
I've started getting a flat file each day of all employees and the usual HR data - not a lot, about 700 employees and 20 fields. Every employee is in the file every day.
Right now I'm working on the ETL piece to get it all into a table, and I think I'll store all the data each day for auditing...
These requirements always leave me grasping for the most efficient approach. I have a table of hospital admissions and readmissions, each record contains an patient number that is unique to the patient and consistent across all admissions. Some visits are flagged in the database as readmissions...
This query works fine:
[code]
select
b.VisitID,
cast(c.ResultRW as numeric(20,2)),
isnumeric(c.ResultRW)
from Livendb.dbo.LabRequisitions a inner join Livendb.dbo.LabSpecimens b
on a.VisitID = b.VisitID
and a.RequisitionID = b.RequisitionID
and a.SourceID = b.SourceID
inner join...
Using SQL Server 2008 R2.
I have a database that is used to store audit information. Recovery mode is simple, and if the entire db got wiped out we could recreate it easily.
One of the tables grew very large - about 230 million records - and the db size is 159 gigs. The log file grew to over...
A1: Y B1: 1 C1: ???
A2: Y
A3: N
Need formula in C1 to return 'Y' if:
B1 = 1 AND A1 = 'Y' and A2 = 'Y' and A3 = 'Y'
OR IF
B1 = 2 and A1 = 'Y' and A2 = 'Y'
Seems like I can get either the test for A cell values or the test for B1 value working, but not all in one formula...
I have a problem report that is getting the 'database configuration incomplete or incorrect' message when scheduling or viewing from BOE 4 server.
I'd like to install Crystal on the server for troubleshooting purposes, but I recall that sometimes this creates problems if not done in a specific...
I'm trying to update a summary table multiple times using a cte for the values - it works fine the first time, but then I get "Invalid object name cte_receipts"
This works:
with cte_receipts as
(select
BillingID,
InsuranceID,
count(BillingID) as ReceiptCount,
sum(Amount) as ReceiptTotal...
New to MySQL - I could probably get this working in SQL Server, but I wouldn't be confident that the syntax would translate.
Simple task: multiple records per customer:
RecordID Customer
1 Joe
2 Joe
3 Joe
4 Joe
5 Sue
6 Sue
7...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.