i have a requirement, i need to find max only one val from each department,i need only one value even 2 person have same max value drop table tst; create table tst(val number,dept varchar2(20),name …
Tag: sql
SQL Query Not Getting Results
What I am doing wrong here? Can anyone please help? 1. Use non-correlated sub-query, find the names of employees who are not working on any projects Answer: SELECT * FROM employee_name WHERE ID IN (…
Understanding the tables referred to in a BigQuery array cross join
I know the namespace isn’t the correct term for this but it conveys what I’m trying to understand. Take this query: WITH Movies AS ( SELECT ‘Titanic’ AS title, 1997 AS year, [‘Drama’,’ Romance’]…
MySQL said: Documentation- Subquery returns more than 1 row
The following renders the correct output. ( SELECT answer_data FROM wp_learndash_pro_quiz_statistic_ref b, wp_learndash_pro_quiz_statistic bb WHERE wp_users.id = b.user_id AND b….
Update column in table with data from another column using Join
I am trying to update data from one column to another using a join statement in SQL. My two tables are rosters and scores. They share playerid. I am trying to add data from scores.opp to rosters.opp. Not sure what I am doing wrong. When I do the select statement below I am able to see the shared playerid, an
Filtering on an array field in BigQuery
I have the following query to get data for a movie: with Movies as ( select ‘Titanic’ as title, 1997 as year, [‘Drama’,’ Romance’] as Genres ) select * from Movies where title=’Titanic’ And to …
Replace the default clustered index with a non-primary/non-key attribute
I have a request to replace the default clustered index with a non-primary attribute and I have an idea of how to simply drop an index and just make another one but I have no clue how to replace the default clustered index. This is as far as I got. However whenever I execute this piece of code I get
How to copy from Parent table to Child Table with 1 column dividing into 3 different column
I have a table column like following Now I want to Divide this column into 3 columns like as How will the SQL Query for this? Answer On MySQL 8+, you could use ROW_NUMBER for this purpose: Demo This approach has an advantage over a union in that it can easily be extended to support more rows and columns as
I can’t get rows have NULL on all rows for column zfeaturekey based on zplid and code type?
I work with SQL Server 2012. I have an issue I can’t get rows from table #gen when it has Null only on all rows on zfeaturekey field based on zplid and codetypeid. I need to get rows that have NULL only on all rows ON zfeaturekey, but must be same codetypeid and same zplid . Output: This is the
Calculating variances within a column
Note: 1st table is the current dataset, 2nd table is the requested result. I was thinking of creating temporary table X and Y which has sales and Sales&Service values data respectively and calculate the variance using a join. I was wondering if that’s the right/convenient way to solve this? Answer I…