Skip to content

Sql query to Count Total Consecutive Years from latest year

I have a table Temp: I want to calculate the total consecutive years starting from the most recent Year. Result should look like this: Answer e.g. for ID=1: As long as there’s no gap, both sequences increase the same. Now check for equal sequences and count the rows: Edit: Based on your year zero commen…

SQL query to generate the following output

Display user id, user name, total amount, amount to be paid after discount and give alias name as User_ID, user_name, Total_amount, Paid_amount. Display record in descending order by user id. Click on TABLE SHCEMA to get the table This is the code I’ve written. But this is not showing the expected resul…

Firebird calc between date skip weekend

I want to convert this sql code to firebird sql for find working days between two dates: CREATE FUNCTION [dbo].fn_CountWeekDays ( @fromdate Datetime, @todate Datetime ) RETURNS TABLE AS RETURN ( …

MSSql server jpa spatial exception

Is it possible to use sql spatial data in jpa? I ve MS SQL Server 2014 Express Edition. I m trying to use spatial data as follows; maven (pom.xml) dependencies; db dialect; spring.jpa.hibernate.dialect=org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect entity definition; @Column(columnDefinit…