I have two data tables: Table KHACHHANG: MAKH TENKH DIACHI DT EMAIL —————————————————————————- KH01 NGUYEN THI BE …
Tag: sql-server
Finding percentage on a sub-query with different where clauses
I am trying to find the percentage completed on a table with a sub-query. I can successfully get the value I need using the following, but I am concerned that I am unnecessarily using two queries to …
SQLDataReader does not show value of column with double colon in field name
A Select query works fine when I enter it in SQL Server Management Studio on SQL Server: SELECT [00:00] FROM MY_TABLE WHERE whatevercondition … The column name is “00:00” – it has a double …
How to check if column has value if another column is populated in SQL Server?
I am trying to find a way to see if I can write a query to check a table to return any row that is missing a dependency if that makes sense. For example let’s say I have the following columns: …
sum columns of a table, grouping by table partition
I have a table which holds daily metrics : |DateID | Metric1 | Metric2| 20190501 24 34 20190502 25 56 ….. …. …. The table has more than 150 million rows. …
In SQL how to calculate days in a year based on a start date and the number of days lapsed
What would be the SQL to calculate the number of days in each year if I had a start date and the number of days that have lapsed? For example, the date (ymd) 2013-01-01 and the days lapsed is 1000. …
Create sql pivot on more row&column
I have to combine in PIVOT multiple columns / rows. let me explain with an example: My start table: PriceListId | ItemId | Stock | PriceIT | PriceES | PriceAT | OriginPriceListId 28 | 25760 | 51 | …
specific select within sql server
I have a table vbap : For all distinct POSNR, PARVW, I need to check if POSNR=POSNR2, if it’s the case I select KUNNR. if POSNRPOSNR2 and POSNR2 =’00000′ I select KUNNR Result: I didn’t …
The reference constraint is being triggered but unable to select rows from the table that would trigger it
I am attempting to update a bunch of different tables in my database. However, when the update is completed, I am unable to delete a record from another table due to a foreign key constraint. However, …
UPDATE all records from existing SELECT query
I have query to select data from related tables. SELECT s.id, CASE WHEN count(DISTINCT e.id) 0 THEN count(DISTINCT o.id) / count(DISTINCT e.id) END …