I’m trying to get a list how many products we’ve sold, per company, by all categories. I’d like the results to look like: Category A Company 1 0 Category A Company 2 0 Category A Company 3 …
Tag: sql
postgresql two NOT LIKE clauses returning wrong results
I have a table with 88 codes. I am writing a simple select statement that does not select the codes that start with 10 or 18 select distinct pcl_mun from exemptions.modiv_parcels_2015 where (pcl_mun …
Query to concatenate rows based on data from multiple rows
I’m trying to print out xml results with a query in SQL Server 2014. The query is supposed return data from a date range, and return a concatenated list of player names and player times. The …
How can i get a count(*) of all the columns in a table? Using PostgreSql
I have bunch of tables where several of them have hundreds of columns. I need to get a count of non-null values for each column and I’ve been doing it manually. I would like to figure out a way to get …
SQL multiple rows calculate
I have a table in SQL Server and I am trying to calculate if a number is bigger than a selected row, but only if the rows that exist are greater than 1. I’ve looked online and looked into Union, …
ms-access-2010 returns #func[exclamation mark]
I have a sql-statement which includes a switch, i want to execute on ms-access-2010. sql: SELECT TABLE_1.ID, SWITCH ( (TABLE_3.ID IN (7,8) AND TABLE_1.SOME_COLUMN = 2), (SELECT MAX(TABLE_4.ID)…
Yii2 How to translate SUM SQL function to Query Builder?
I have this simple SQL query: SELECT product_name, SUM (product_amount) FROM orders GROUP BY product_name; It will show a list with product names and their amounts. Like this example: I want to …
Knex query returning bool logic
I am writing some knex queries to check if a supplied code otherwise known as a voucher is legitimate under 4 constraints. The voucher exists The voucher has not expired The voucher is for the …
How subquery works?
My understanding of the logical order of execution of sql query is that FROM which gives us the base set of data WHERE which filters the base set data SELECT returning the filtered data I am not able to wrap my head around in the working of this query which contains a subquery:- I mean here, when WHERE is filtering
MySQL – Select where first character is lowercase or uppercase
Sorry if this is something that was asked before, but I am not able to find the answer to this. How do I create a MySQL select statement to select all strings from the database whose first characters …