I have a column with phone numbers in varchar, currently looks something like this. Because there is no consistent format, I don’t think substring works. (956) 444-3399 964-293-4321 (929)293-1234 (919)2991234 How do I remove all brackets, spaces and dashes and have the query return just the digits, in S…
SQL GROUP BY columns with inverted values
Suppose I’ve a table with like this: Where G1, G3 are VARCHAR and G2, G4 are INT If I do a simple GROUP BY on G1..G4 I get: I’m wondering if is possible to aggregate on inverted value G1,G2 <-> G3,G4. What I want to achieve is a result like this: What I tried is to get the inverted rows,
How to return the highest value in a sequence for each ID unless one has been skipped, with SQL?
I want to return the columns listed below but would like it grouped by JobNumber and only return the maximum StageNum so long as it has not skipped any stages. For example, my table currently looks like this: ID Stage StageNum Date 104 Released 10 2022-02-07 104 Slab 20 2022-02-18 104 Frame 30 2022-03-07 104 …
SELECT from Multiple IF conditions in Where Clause
I have a following query In the above query I need to add IF condition that IF a.Type is Accessories then I need certain a.Brands to select from and if a.Type is Clothing then I need to select from certain a.Brands Answer Use a CASE expression, but you should also write a proper join with an ON clause for the
Is it possible to populate a c# list box with a Row of data from sql server
So, I am new to C#, Visual studio etc, however I have a bit of experience with SQL Server. I Have a table, that contains Data (Obviously), and what I am trying to do is retrieve that data and display it in a drop down list so that a client can select which one they want. The problem I have
Make custom Restriction NHibernate for QueryOver
I’m stuck in a simple problem, I’d like to add a new custom restriction in NHibernate. I want to write a simple QueryOver with a fulltext index, an example with a Projections is here How to use Full Text Search for any property with QueryOver API But I need a more flexibility so I’d like som…
MySQL query to update field in a table based on value of other field in same table
I’ve been trying to figure out the correct query for the following issue and I cannot seem to find the solution myself. I’m running a WooCommerce store which stores a bunch of values as ‘meta_key’ in a MySQL table with the value stored in the ‘meta_value’ column. What I wan…
BigQuery JSON – Scalar subquery produced more than one element
I am trying to parse this json in BQ. My desired output is variant helm,chart I have tried the query below and I get the error: Scalar subquery produced more than one element.. If I rewrite this to use a nested arrays, everything works perfect. however, when I try to use a scalar subquery by following the sam…
SQL query: Extra line with no data
I´m trying to get the first 10 records when concatenating two strings, counting the number of records for these, and getting the average duration of the trips. The query jeeps showin the first line of the results with no data (maintaining the “to” in the route column, and null duration) what it af…
Variable in dateadd function snowflake
I have a query like this: It gives this error: Single row subquery returns more than one row. Is there a way to pass a variable in the 3rd argument of dateadd function? Because my cte will return many min_date based on the group by clause. TIA Answer Yes, sub-select in SELECT need to only return one row, you …