Split a column in SELECT

I'm trying to get all records where I have a column concatenated with a :. SELECT serName FROM tblService WHERE serBqtID=1; The data stored in table as like this: serName serStatus ------- --------- catering Ava...
more »

2017-11-11 19:11 (2) Answers

Derby database BOOLEAN not recognized after create

I am trying to create and use and embedded database in Eclipse. So this is why I am using Derby. I am creating a table named "users2" (because I want to test things on it). When I create a SQL script and having "BOOLEAN" field it succeed. And then ...
more »

2017-11-11 17:11 (0) Answers

SQL getting Percentage

I have the following code to calculate total fatalities and group by the PersonType. Now I want to have a column that calculates the percentage of each fatalities. that is taking the value for each person type and dividing by the total fatalities. S...
more »

2017-11-11 15:11 (2) Answers

SQL Server 2012 database query issue

I have a query which I am trying to resolve but could not able to make it happen. Below is the query which needs to evaluate. Declare @Table Table(SSYId INT, Name VARCHAR(100), Address VARCHAR(100), ParentSSYId INT, RelationWithParentSSY VARCHAR(50...
more »

2017-11-11 12:11 (1) Answers

How to filter records by them amount per date?

i have a tablet 'A' that have a column of date. and the same date can be in a few records. I'm trying to filter the records where the amount of the records by day is less than 5. And still keep all the fields of the tablet. I mean that if i have onl...
more »

2017-11-10 01:11 (2) Answers

Recusive lookup needed. DB vs C# GUI

I currently have a program in which I want to list 'support tickets' in a grid. The tickets are coming from a SQL DB out of a ticketing system. A ticket has an activity, example: I have a fully functional design but have a problem to list the ...
more »

2017-11-09 22:11 (2) Answers

SQL Server: Round Date Up

I want to round a datetime value up to the nearest full day. UPDATE [DB].[dbo].[TABLE] -- I'm unsure how to take the DepartureDate and round it up SET DepartureDate = DepartureDate + ?? WHERE DATEPART(HOUR, DepartureDate) = 23 The DepartureDate is...
more »

2017-11-09 17:11 (3) Answers

Select an element in nested XML in SQL Server

I have a column with XML contents in a SQL Server table. Actually, several different XML's are merged together in this particular XML column. When I do select columnwithXML.query('(/root/secondlayer/node())').value('(/*)[11]', 'varchar(max)')...
more »

2017-11-09 15:11 (1) Answers

Return numerous SQL results to C# array

I have seen a few questions asked about this kind of thing already, but whenever I try anything it just doesn't work with this exact instance. I have a remote SQL SERVER database set up, and it has over 2000 rows. This is my C#: command.Connection ...
more »

2017-11-09 00:11 (1) Answers

Spring Data JPA filter on ManyToMany

I have the following scenario. A user makes a REST request to my server (http://localhost/server/folders). The server knows the user and should now only respond with relevant information for the user, which means show only folders where the user is r...
more »

2017-11-08 14:11 (0) Answers

Use auto incremented ID in another column

I have two columns in my DB table, where the first one is auto incremented ID. In the second one I would like to have that ID mirrored. (I know it sound like design error, but I really need it) Is it possible to configure it that way? ...
more »

2017-11-08 13:11 (3) Answers

Rank records in sets based on multiple fields

╔════════════════════╦═══════════╦══════════╦═══════╦══════╗ ║ ENDTIME ║ TRAILERID ║ POSITION ║ STORE ║ STOP ...
more »

2017-11-07 23:11 (1) Answers

Group rows with Id from specific row

I've been breaking my head trying to work this out, so some help here would be appreciated very much. Basically I've got a database table, for example: I'm trying to get the below result: Id | Name | Total ------------------------ 590954 | ...
more »

2017-11-07 15:11 (4) Answers

Sql Server Count with date range

Here is my sample query create table #Date(date date, count int) create table #Reservation(arrival date, departure date, name varchar(50)) insert into #Reservation(arrival,departure,name) values('2017-11-05','2017-11-07','LeBron James') insert i...
more »

2017-11-07 15:11 (4) Answers

SQL Constraints OR Condition

How can I have an SQL constraint with an OR condition: USE [dbname] GO ALTER TABLE [dbo].[tablename] WITH NOCHECK ADD CONSTRAINT [CK_table] CHECK (([field1] like ('[0-9a-zA-Z][0-9a-zA-Z]' OR '[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]') AND [field1] IS N...
more »

2017-11-06 17:11 (2) Answers

Group and Personal Permission Design MVC

We currently have a structure that gives certain users roles and associates their roles with permissions, which are essentially features. EditUser, ViewUser, etc. When the user logs in it loads all of their permissions into the auth cookie and our ...
more »

2017-11-05 23:11 (1) Answers

join, union 3 tables in sql

Please, help me to solve my sql problem. In my DB I have 3 tables as following I have wrote a query that display the total refunded and total invoiced and the method has been used to refund or invoice (cash, credit card or checkout) for a specific ...
more »

2017-11-05 18:11 (1) Answers

What can I use other than Group By?

I have a question that uses this DML statement SELECT SupplierID, COUNT(*) AS TotalProducts FROM Products GROUP BY SupplierID; I'm trying to get the same results without using "Group By". I can use a table variable or a temp table, with Insert and...
more »

2017-11-05 15:11 (4) Answers