Skip to content
Advertisement

Tag: sql

SQL to find local count max per primary key

I have a table with PK CustomerId + type. Each customer has a few types. For each customer I want to get type which repeated the most for this customer. I’ve tried to create a column “count” but I want to get the local maxs, and not a global max for the whole col. Is there a native way to

Word unscrambler in MySQL

Let’s say I have the input string “Hello” I want to be able to retrieve these output words: hole, lol, eh, hell All the output words letters should be contained in the input string. How I should be able to achieve that? I’ve tried to use like: But this returns words such as: hi، loop,etc.. but I need the all

Sql list unregistered classroom

There is one student. This student is enrolling in classes. What I want is to list the classes where this student is not registered. My SQL query is like this. Where am I going wrong? Answer I had to assume your table structure and I hope I got it right. The classic approach would be with LEFT JOIN and IS

Schema-validation: wrong column type encountered in column

Error: Schema-validation: wrong column type encountered in column [curr_step] in table [risk_workflow]; found [varchar2 (Types#VARCHAR)], but expecting [number(19,0) (Types#BIGINT)] Please let me know how can we solve this? Column declaration in entity class “risk_workflow” WorkflowTaskRoleMapping entity: Answer The id of WorkflowTaskRoleMapping is a long and Hibernate maps it on the db with a column of type number(19,0). Hibernate expects the

Sybase select value from XML field

I have a table named data_values stored in SYBASE in the following format: The value field has the following XML format: I want to select from the value field values like value1, value2, etc. but I can’t find a correct query to do this. I have tried: also value is a reserved keyword I think and I need to escape

How to create an ID column based on condition of previous row?

I am trying to group hospital admission transfers, with the initial index admission. So far I have been able to categorize each admission as ‘index’ or ‘transfer’ based on the time since previous discharge. Now I am trying to group together the admissions together that are in the same episode of care (e.g. each index admission and its associated transfers).

SQL/MYSQL /Transpose table / Columns into rows and rows sum as column with new header

i have a table like this Its simple in Excel sheets but im stuck in MySql Appreciate the help Thanks — SeasonType,Sacks,SacksYards are columns — union all attempt column sacks,sacksyards table — — fantasydefencegame Answer This should fairly give you some ideas. Supposing we are using a test database named testdb and your original table is named test which has

Advertisement