w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » SQL » Page 1
Add more than one filter to a query using same column
Change the Where condition like this. Use OR operator or IN Clause instead of AND The AND operator displays a record if both the first condition AND the second condition are true. The OR operator displays a record if either the first condition OR the second condition is true. WHERE DATEDIFF(YEAR, A.AcquiredDate, GetDate()) >=5 AND A.AssetTypeID = 7 AND (A.CategoryID = 5 or A.Catego

Categories : SQL

Is there a way to perform a cross join or Cartesian product in excel?
Try using a CROSS JOIN. Read more at MSDN You can use the expression CROSSJOIN(table1, table2) to create a cartesian product.

Categories : SQL

Show same columns with different values (and empty values)
This is not something you are supposed to do with SQL. Don't do it with SQL, it would be complex to develop and maintain. SQL helps you retrieve your data, you are able to do some kind of presentation stuff, but as soon as it becomes too complex, you know you are having the wrong approach. You should do this kind of presentation in your front end application

Categories : SQL

How to show that something does increases the expressive power?
First you must decide what is that is being expressed by two notations. (Ie what it is that they are expressing, ie are expressive of, ie are denoting.) Otherwise, the problem doesn't make much sense. Eg: As long as two notations' sets of expressions are countably infinite they can be set in 1:1 correspondence. So anything that one set's expressions can express the corresponding expression from t

Categories : SQL

Interleave two SQL columns into paired array
This solution is very specific to this case (i.e. 2 items per id) so it might not be sufficient but it does work in your case: select id , ARRAY[min(kv), max(kv)] from (select id , ARRAY[key, val] kv from fruit ) s group by id order by id; ┌────┬───────────────────────┐ │ id │ array

Categories : SQL

SQL query use of Group by functions with tricky logic
select y.Item, y.SubItem, y.GroupQty from ( -- Rank the items by quantity and exclude the items that only have 1 subitem. select x.Item, x.SubItem, x.GroupQty, dense_rank() over (partition by x.Item order by x.GroupQty) as GroupRank from ( -- Group by item and subitem. Sum quantity and count the number of subitems per item. select

Categories : SQL

Fast way to count rows of a cursor
You can do like this, pass a variable to function and function would store amount of rows in it: function search_foo(param1 varchar2, param1 varchar3, PARAM_ROWCOUNT OUT NUMBER) -- here return g_ref -- a ref cursor is l_return g_ref; { open l_return for select col1_i_need, col2_i_need from foo join bar on --[...] where [...]; PARAM_ROWCOUNT := l_return%ROWCOUNT;

Categories : SQL

Aggregation query: group and count by multiple number of dynamically selected columns
select user_profile, page_viewed, count(*) as cnt, '# session_ids ' || STRING_AGG(session_id, ' and ' order by session_id) as sess from ( select max(case when event_type = 'user_profile' then event_value else null end) as user_profile, max(case when event_type = 'page_viewed' then event_value else null end) as page_viewed, ses

Categories : SQL

Access Linking Subform to Tab Control in Main Form
You wouldn't be able to update any information if the table is opened simultaneously 5 times. If it's at all possible, I'd suggest using a Combo Box to allow your users to filter based on any number of criteria, and then pass the SelectedValue of the Combo Box into the RecordSource of the form: Dim MySQL as String MySQL = "SELECT * FROM MyTable WHERE MyField = '" & Me.MyComboBox.SelectedVal

Categories : SQL




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.