I have a table called Fare: CREATE TABLE Fare ( Date DATE NOT NULL, CardFare VARCHAR(5) NOT NULL, FullFare VARCHAR(5) NOT NULL ) I have to group by date and sum cardfare and fullfare …
Tag: sql
Query response in JSON format without column name
My table schema is something like this, Initially, my procedure was returning with data as After processing the data, to the web page is sent as If I use the result will be like So what I need to get is the same response but without column name, as front-end lib uses the JSON array without keys. SQL Server ve…
SQL group by (count,sum)
Hello i need help abou SQL a have this table and i need this result. thanks for your attention and your answers. select to_char(r.date,’yyyy’) YEAR, sum(1), sum(r.cafe) cafe, sum(r.drink) drink, …
Split a string into two fields based on multiple words
I have the following column in my Table name:STAT It would be helpful if someone can assist in writing a mysql script I would like to split the strings in to 2 columns. However the split should happen only based on the last word, i.e the Region as can be seen in the example below. There is an exception that
Converting multiple rows into one row by ID
What I am trying to achieve is group them by id and create a column for the date as well as data. The background of the dataset are it is lab result taken by participant and some test are not able to …
DB2 Crystal Reports Declare/Set Variable
I am using Crystal Reports to pull data from DB2 10.5. I need to calculate a specific date and then use this calculated date as a filter. Here is an example of how I am currently achieving this. WITH …
SQL Select in an Insert statement
How can I combine these two scripts? I basically don’t want to hard code the number 34 in Query 2. I want the script to take the next number of job_id. Query 1 returns 34, so Query 2 should take 35 as …
How to calculate difference between 2 time columns in distinct tables?
I need to calculate the difference between EntryHourSchedule (the ideal time) and EntryHourRegistered (the real time) of a worker’s assitance, but both are in 2 different tables: ScheduleDetail (* to …
How to fix Nested CASE Syntax Error “Invalid Number of Arguments” in Oracle SQL
Im running a query in Oracle and am trying to create a new column that is defined by the nested CASE statement below. I get an error on the highlighted “Else” statement saying “Invalid Number of …
SQL refer Primary Key in same Table and Query
I am maintaining a table of Items (Id is Primary Key). Some Items have Parent Item ( Which is also an Item, the colum Parent holds the Id of the parent Item, which is also in the same table. Some …