I am looking to make a query in SQL SERVER that will allow me to display in a grouping the string that appears in most cases. Not the amount, not the maximum, but the string that is displayed in most cases: colA colB colC A 10 ccc A 20 aaa A 35 bbb A 25 aaa A 10 aaa B
Tag: select
REACT: SELECT from MYSQL
i a new user and a new in React world. I need help to solve this situation about a Select with values from mysql DB. I receive the values, but the select goes in infinite loop. The error is surely in this file cause server.js works without problem!! Really thanks for the help, and sorry if it could be a
SQL method for returning data from multiple tables based on column names
I am trying to do something a little weird and cannot figure out the right method for getting it done. Essentially I am trying to pull all tables/views and columns where the column name is like some string. In addition to that I would like to pull 1 row of data from that table/view and column combination. The second part
Dates returned as columns in SQL Select
My user will submit a FromDate and a ToDate. What I want to happen is to select the dates that fall in between these dates, which I have accomplished with the script below. The dates will by dynamic. This returns that dates as rows. What I am looking for is a way to make these dates return as the columns
Select Distinct Rows with complex criteria
I have a table generated from a CRM software and it has a lot of repited individuals in different rows but with different fields completed in each repetition, something like this: id birth_date sex postal_code customer smoker 001 NULL NULL 00067 Yes 1 001 NULL Male 00067 NULL 1 001 21/03/1994 NULL 00067 NULL NULL 002 NULL Female NULL NULL
SQL – combined SELECT queries and getting a % output
I am using SQLiteStudio and I am trying to run the following query. However, it isn’t returning a value. Can anyone help, please? I have been asked to provide some of the data. Below I have included how I created my 3 tables and then some sample data for each section. Hopefully, this is enough but feel free to ask
Calculate total difference of values between two timestamps
DB-Fiddle Expected Result: I want to calculate the total difference of the quantity between two timestamps. Therefore, I tried to use the query from this question: However, I am not able to get the expected result. What do I need to change to make it work? Answer The partition by clause in the lag call of your query is redundant.
Case statements with Join on lookup
I have a big table with some columns having lookup values. I want to create a description column for each lookup column and populate them with description from lookup table. Here is one example main table id1 id2 id3 1 2 3 1 3 4 look up table code id desc id1 1 id1-desc1 id2 2 id2-desc2 id2 3 id2-desc3
How to select rows from table when a column repeats?
I have this table (REGIONS) with this sample values: Id Cod1 Cod2 Payed 1 0001 000A NULL 2 0001 000B YES 3 0001 000B YES 4 0001 000C NULL 5 0001 000C YELL 6 0001 000D NULL 7 0002 000A YES 8 0002 000C NULL 9 0002 000C NULL 10 0002 000C YES 11 0003 000C YES 12 0004 000C
subquery double where + aggreate functions
I have table and rows I want to have sum of balance and payed for simple users with approvedAdminId (isSimpleUser = 1 AND approvedAdminId is not NULL) and for not simple users (isSimpleUser = 0) Expected Result Answer Output: